Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/IAP fixes #37

Merged
merged 18 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-11-03T18:35:32.151Z\n"
"PO-Revision-Date: 2024-11-03T18:35:32.151Z\n"
"POT-Creation-Date: 2024-11-08T16:32:23.115Z\n"
"PO-Revision-Date: 2024-11-08T16:32:23.115Z\n"

msgid "Low"
msgstr ""
Expand Down Expand Up @@ -87,9 +87,6 @@ msgstr ""
msgid "Edit Action Plan"
msgstr ""

msgid "Event completed"
msgstr ""

msgid "Edit Details"
msgstr ""

Expand Down Expand Up @@ -174,6 +171,18 @@ msgstr ""
msgid "Risks associated with this event have not yet been assessed."
msgstr ""

msgid "Complete event"
msgstr ""

msgid "Not now"
msgstr ""

msgid "Complete"
msgstr ""

msgid "Are you sure you want to complete this Event? This cannot be undone."
msgstr ""

msgid "N/A"
msgstr ""

Expand Down
29 changes: 19 additions & 10 deletions i18n/es.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
"POT-Creation-Date: 2024-10-15T13:56:24.806Z\n"
"POT-Creation-Date: 2024-11-08T16:32:23.115Z\n"
"PO-Revision-Date: 2018-10-25T09:02:35.143Z\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -89,6 +89,9 @@ msgstr ""
msgid "Edit Details"
msgstr ""

msgid "Complete Event"
msgstr ""

msgid "Notes"
msgstr ""

Expand Down Expand Up @@ -167,6 +170,18 @@ msgstr ""
msgid "Risks associated with this event have not yet been assessed."
msgstr ""

msgid "Complete event"
msgstr ""

msgid "Not now"
msgstr ""

msgid "Complete"
msgstr ""

msgid "Are you sure you want to complete this Event? This cannot be undone."
msgstr ""

msgid "N/A"
msgstr ""

Expand Down Expand Up @@ -194,6 +209,9 @@ msgstr ""
msgid "Incident Response Actions saved successfully"
msgstr ""

msgid "Incident Management Team Member saved successfully"
msgstr ""

msgid "Create an incident action plan"
msgstr ""

Expand All @@ -203,21 +221,12 @@ msgstr ""
msgid "Create IAP"
msgstr ""

msgid "Incident Management Team Member saved successfully"
msgstr ""

msgid "Incident Action Plan"
msgstr ""

msgid "Incident Management Team Builder"
msgstr ""

msgid "Cholera in NW Province, June 2023"
msgstr ""

msgid "Incident Management Team Builder"
msgstr ""

msgid "Edit Role"
msgstr ""

Expand Down
1 change: 0 additions & 1 deletion src/data/repositories/IncidentActionD2Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export type IncidentResponseActionDataValues = {
subPillar: Maybe<string>;
searchAssignRO: Maybe<string>;
dueDate: Maybe<string>;
timeLine: Maybe<string>;
status: Maybe<Status>;
verification: Maybe<Verification>;
};
Expand Down
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
2 changes: 0 additions & 2 deletions src/data/repositories/consts/IncidentActionConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export const responseActionConstants = {
subPillar: "RTSL_ZEB_DET_SUB_PILLAR",
searchAssignRO: "RTSL_ZEB_DET_SEARCH_ASSIGN_RO",
dueDate: "RTSL_ZEB_DET_DUE_DATE",
timeLine: "RTSL_ZEB_DET_TIMELINE",
status: "RTSL_ZEB_DET_STATUS",
verification: "RTSL_ZEB_DET_VERIFICATION",
} as const;
Expand Down Expand Up @@ -127,7 +126,6 @@ export function getValueFromIncidentResponseAction(
RTSL_ZEB_DET_SUB_PILLAR: incidentResponseAction.subPillar || "",
RTSL_ZEB_DET_SEARCH_ASSIGN_RO: incidentResponseAction.searchAssignRO?.username || "",
RTSL_ZEB_DET_DUE_DATE: incidentResponseAction.dueDate.toISOString(),
RTSL_ZEB_DET_TIMELINE: incidentResponseAction.timeLine || "",
RTSL_ZEB_DET_STATUS: incidentResponseAction.status,
RTSL_ZEB_DET_VERIFICATION: incidentResponseAction.verification,
};
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
10 changes: 10 additions & 0 deletions src/data/repositories/utils/DateTimeHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,13 @@ export function getDateAsLocaleDateString(date: Date): string {
export function getISODateAsLocaleDateString(date: string): Date {
return moment.utc(date).local().toDate();
}

const getQuarter = (month: number): number => Math.ceil((month + 1) / 3);

export function formatQuarterString(date: Date): string {
const year = date.getFullYear();
const month = date.toLocaleString("default", { month: "short" });
const quarter = getQuarter(date.getMonth());

return `Qtr ${quarter}, ${month} ${year}`;
}
31 changes: 17 additions & 14 deletions src/data/repositories/utils/IncidentActionMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export function mapDataElementsToIncidentResponseActions(
const subPillar = getValueById(dataValues, incidentResponseActionsIds.subPillar);
const searchAssignRO = getValueById(dataValues, incidentResponseActionsIds.searchAssignRO);
const dueDate = getValueById(dataValues, incidentResponseActionsIds.dueDate);
const timeLine = getValueById(dataValues, incidentResponseActionsIds.timeLine);
const status = getValueById(dataValues, incidentResponseActionsIds.status) as Status;
const verification = getValueById(
dataValues,
Expand All @@ -91,7 +90,6 @@ export function mapDataElementsToIncidentResponseActions(
subPillar,
searchAssignRO,
dueDate,
timeLine,
status,
verification,
};
Expand Down Expand Up @@ -173,19 +171,24 @@ export function mapIncidentResponseActionToDataElements(
const dataElementValues: Record<ResponseActionCodes, string> =
getValueFromIncidentResponseAction(incidentResponseAction);

const dataValues: DataValue[] = programStageDataElementsMetadata.map(programStage => {
if (!isStringInIncidentResponseActionCodes(programStage.dataElement.code)) {
throw new Error(
`DataElement code ${programStage.dataElement.code} not found in Incident Action Plan Codes`
const dataValues: DataValue[] = programStageDataElementsMetadata
.filter(
programStageDataElement =>
programStageDataElement.dataElement.id !== incidentResponseActionsIds.timeLine
)
.map(programStage => {
if (!isStringInIncidentResponseActionCodes(programStage.dataElement.code)) {
throw new Error(
`DataElement code ${programStage.dataElement.code} not found in Incident Action Plan Codes`
);
}
const typedCode: IncidentResponseActionKeyCode = programStage.dataElement.code;

return getPopulatedDataElement(
programStage.dataElement.id,
dataElementValues[typedCode]
);
}
const typedCode: IncidentResponseActionKeyCode = programStage.dataElement.code;

return getPopulatedDataElement(
programStage.dataElement.id,
dataElementValues[typedCode]
);
});
});

return getIncidentActionTrackerEvent(
programStageId,
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: 0 additions & 1 deletion src/domain/entities/incident-action-plan/ResponseAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ interface ResponseActionAttrs {
subPillar: string;
searchAssignRO: Maybe<TeamMember>;
dueDate: Date;
timeLine: string;
status: Status;
verification: Verification;
}
Expand Down
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(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

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
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export function getIncidentAction(
dueDate: responseActionDataValue?.dueDate
? new Date(responseActionDataValue.dueDate)
: new Date(),
timeLine: responseActionDataValue?.timeLine ?? "",
status: status,
verification: verification,
});
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
Loading
Loading