Skip to content

Commit

Permalink
Merge pull request #37 from EyeSeeTea/fix/iap-fixes
Browse files Browse the repository at this point in the history
Fix/IAP fixes
  • Loading branch information
bhavananarayanan authored Nov 11, 2024
2 parents 7421322 + 3c42eef commit 4dd6a86
Show file tree
Hide file tree
Showing 29 changed files with 367 additions and 138 deletions.
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-07T10:23:53.316Z\n"
"PO-Revision-Date: 2024-11-07T10:23:53.316Z\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 @@ -177,6 +174,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
38 changes: 31 additions & 7 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 All @@ -98,6 +101,9 @@ msgstr ""
msgid "Currently assigned:"
msgstr ""

msgid "Error loading current Incident Management Team"
msgstr ""

msgid "Create Event"
msgstr ""

Expand Down Expand Up @@ -167,6 +173,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 +212,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,16 +224,13 @@ msgstr ""
msgid "Create IAP"
msgstr ""

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

msgid "Incident Action Plan"
msgstr ""

msgid "Incident Management Team Builder"
msgid "Team"
msgstr ""

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

msgid "Incident Management Team Builder"
Expand All @@ -224,10 +242,16 @@ msgstr ""
msgid "Assign Role"
msgstr ""

msgid "Delete Roles"
msgstr ""

msgid "Delete Role"
msgstr ""

msgid "Delete team role"
msgid "Confirm deletion"
msgstr ""

msgid "Delete"
msgstr ""

msgid "Resources"
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(),
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 @@ -65,6 +65,7 @@ export function getTestContext() {
all: [],
riskAssessors: [],
incidentManagers: [],
responseOfficers: [],
},
},
};
Expand Down
Loading

0 comments on commit 4dd6a86

Please sign in to comment.