Skip to content

Commit

Permalink
feat: use incident response officer user group
Browse files Browse the repository at this point in the history
  • Loading branch information
deeonwuli committed Nov 8, 2024
1 parent a0a0f55 commit 9d2a7bb
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 28 deletions.
5 changes: 5 additions & 0 deletions src/data/repositories/TeamMemberD2Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Future } from "../../domain/entities/generic/Future";
const RTSL_ZEBRA_INCIDENTMANAGER = "RTSL_ZEBRA_INCIDENTMANAGER";
const RTSL_ZEBRA_RISKASSESSOR = "RTSL_ZEBRA_RISKASSESSOR";
const RTSL_ZEBRA_INCIDENT_MANAGEMENT_TEAM_MEMBERS = "RTSL_ZEBRA_INCIDENT_MANAGEMENT_TEAM_MEMBERS";
const RTSL_ZEBRA_INCIDENT_RESPONSE_OFFICERS = "RTSL_ZEBRA_INCIDENT_RESPONSE_OFFICERS";

export class TeamMemberD2Repository implements TeamMemberRepository {
constructor(private api: D2Api) {}
Expand Down Expand Up @@ -42,6 +43,10 @@ export class TeamMemberD2Repository implements TeamMemberRepository {
return this.getTeamMembersByUserGroup(RTSL_ZEBRA_INCIDENT_MANAGEMENT_TEAM_MEMBERS);
}

getIncidentResponseOfficers(): FutureData<TeamMember[]> {
return this.getTeamMembersByUserGroup(RTSL_ZEBRA_INCIDENT_RESPONSE_OFFICERS);
}

private getTeamMembersByUserGroup(userGroupCode: string): FutureData<TeamMember[]> {
return apiToFuture(
this.api.metadata.get({
Expand Down
16 changes: 16 additions & 0 deletions src/data/repositories/test/TeamMemberTestRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ export class TeamMemberTestRepository implements TeamMemberRepository {
return Future.success([teamMember]);
}

getIncidentResponseOfficers(): FutureData<TeamMember[]> {
const teamMember: TeamMember = new TeamMember({
id: "incidentResponseOfficer",
username: "incidentResponseOfficer",
name: `Team Member Name test`,
email: `[email protected]`,
phone: `121-1234`,
teamRoles: undefined,
status: "Available",
photo: new URL("https://www.example.com"),
workPosition: "workPosition",
});

return Future.success([teamMember]);
}

getAll(): FutureData<TeamMember[]> {
const teamMember: TeamMember = new TeamMember({
id: "test",
Expand Down
1 change: 1 addition & 0 deletions src/domain/entities/AppConfigurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ export type Configurations = {
all: TeamMember[];
riskAssessors: TeamMember[];
incidentManagers: TeamMember[];
responseOfficers: TeamMember[];
};
};
1 change: 1 addition & 0 deletions src/domain/repositories/TeamMemberRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export interface TeamMemberRepository {
getIncidentManagers(): FutureData<TeamMember[]>;
getRiskAssessors(): FutureData<TeamMember[]>;
getForIncidentManagementTeamMembers(): FutureData<TeamMember[]>;
getIncidentResponseOfficers(): FutureData<TeamMember[]>;
}
64 changes: 36 additions & 28 deletions src/domain/usecases/GetConfigurationsUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,47 @@ export class GetConfigurationsUseCase {
) {}

public execute(): FutureData<Configurations> {
return this.teamMemberRepository.getIncidentManagers().flatMap(managers => {
return this.teamMemberRepository.getRiskAssessors().flatMap(riskAssessors => {
return this.teamMemberRepository.getAll().flatMap(teamMembers => {
return this.configurationsRepository
.getSelectableOptions()
.flatMap(selectableOptionsResponse => {
const selectableOptions: SelectableOptions =
this.mapOptionsAndTeamMembersToSelectableOptions(
selectableOptionsResponse,
managers,
riskAssessors,
teamMembers
);
const configurations: Configurations = {
selectableOptions: selectableOptions,
teamMembers: {
all: teamMembers,
riskAssessors: riskAssessors,
incidentManagers: managers,
},
};
return Future.success(configurations);
});
});
});
});
return Future.joinObj({
allTeamMembers: this.teamMemberRepository.getAll(),
incidentResponseOfficers: this.teamMemberRepository.getIncidentResponseOfficers(),
managers: this.teamMemberRepository.getIncidentManagers(),
riskAssessors: this.teamMemberRepository.getRiskAssessors(),
selectableOptionsResponse: this.configurationsRepository.getSelectableOptions(),
}).flatMap(
({
allTeamMembers,
incidentResponseOfficers,
managers,
riskAssessors,
selectableOptionsResponse,
}) => {
const selectableOptions: SelectableOptions =
this.mapOptionsAndTeamMembersToSelectableOptions(
selectableOptionsResponse,
managers,
riskAssessors,
incidentResponseOfficers
);

const configurations: Configurations = {
selectableOptions: selectableOptions,
teamMembers: {
all: allTeamMembers,
riskAssessors: riskAssessors,
incidentManagers: managers,
responseOfficers: incidentResponseOfficers,
},
};
return Future.success(configurations);
}
);
}

mapOptionsAndTeamMembersToSelectableOptions(
selectableOptionsResponse: SelectableOptions,
managers: TeamMember[],
riskAssessors: TeamMember[],
teamMembers: TeamMember[]
incidentResponseOfficers: TeamMember[]
): SelectableOptions {
const selectableOptions: SelectableOptions = {
eventTrackerConfigurations: {
Expand All @@ -66,7 +74,7 @@ export class GetConfigurationsUseCase {
},
incidentResponseActionConfigurations: {
...selectableOptionsResponse.incidentResponseActionConfigurations,
searchAssignRO: teamMembers,
searchAssignRO: incidentResponseOfficers,
},
};

Expand Down
1 change: 1 addition & 0 deletions src/utils/tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export function getTestContext() {
all: [],
riskAssessors: [],
incidentManagers: [],
responseOfficers: [],
},
},
};
Expand Down

0 comments on commit 9d2a7bb

Please sign in to comment.