From d38add9ad2bd1b4d17b719167d8f7ffd7b565241 Mon Sep 17 00:00:00 2001 From: chelsea-EYDS Date: Fri, 17 Jan 2025 22:59:11 -0800 Subject: [PATCH 1/2] fix recommitment program on member profile and dashboard banner --- .../entities/emcr/emcr-personnel.entity.ts | 3 ++- backend/src/personnel/personnel.service.ts | 1 + docker-compose.yml | 5 ++--- .../profile/banners/RecommitmentDashBanner.tsx | 9 ++------- .../InitialRecommitmentDropdown.tsx | 2 +- .../recommitment/RecommitmentFormBase.tsx | 2 +- .../components/recommitment/SupervisorForm.tsx | 4 ++-- .../src/components/table/body/TableBodyCell.tsx | 9 ++++----- frontend/src/hooks/useMemberProfile.tsx | 17 ++++++++++++++++- frontend/src/pages/profile/MemberProfile.tsx | 5 +++-- 10 files changed, 34 insertions(+), 23 deletions(-) diff --git a/backend/src/database/entities/emcr/emcr-personnel.entity.ts b/backend/src/database/entities/emcr/emcr-personnel.entity.ts index 7b1dc7bf..1e636f52 100644 --- a/backend/src/database/entities/emcr/emcr-personnel.entity.ts +++ b/backend/src/database/entities/emcr/emcr-personnel.entity.ts @@ -164,7 +164,8 @@ export class EmcrPersonnelEntity { status: this.status, travelPreference: this.travelPreference, newMember: - Status.ACTIVE && differenceInDays(new Date(), this.dateApproved) < 6, + this.status === Status.ACTIVE && + differenceInDays(new Date(), this.dateApproved) < 6, icsTraining: this.trainings?.some((t) => t.name === ICS_TRAINING_NAME) || false, experiences: diff --git a/backend/src/personnel/personnel.service.ts b/backend/src/personnel/personnel.service.ts index 1af434b9..f042803d 100644 --- a/backend/src/personnel/personnel.service.ts +++ b/backend/src/personnel/personnel.service.ts @@ -451,6 +451,7 @@ export class PersonnelService { queryBuilder.addOrderBy('personnel.lastName', 'ASC'); queryBuilder.addOrderBy('personnel.firstName', 'ASC'); } else if (status === Status.ACTIVE) { + //TODO - Fix this (not sure if the order by is being added here) queryBuilder.addSelect( `CASE WHEN emcr_personnel.dateApproved > current_date - interval '5' day THEN emcr_personnel.dateApproved ELSE null END`, 'new_member', diff --git a/docker-compose.yml b/docker-compose.yml index b666c928..b5058b96 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -91,10 +91,11 @@ services: DB_PASSWORD: ${DB_PASSWORD} MODE: ${MODE} END_RECOMMITMENT_SCHEDULE: ${END_RECOMMITMENT_SCHEDULE} - TEST_EMAIL: ${TEST_EMAIL} CHOKIDAR_USEPOLLING: true ALLOW_EMPTY_PASSWORD: "yes" ENV: ${ENV} + TEST_EMAIL: ${TEST_EMAIL} + TEST_RUN: ${TEST_RUN} networks: - tc keycloak: @@ -128,8 +129,6 @@ services: HEALTH_ENABLED: "true" HTTP_ENABLED: "true" METRICS_ENABLED: "true" - TEST_EMAIL: ${TEST_EMAIL} - TEST_RUN: ${TEST_RUN} depends_on: - db ports: diff --git a/frontend/src/components/profile/banners/RecommitmentDashBanner.tsx b/frontend/src/components/profile/banners/RecommitmentDashBanner.tsx index a917475b..127cf006 100644 --- a/frontend/src/components/profile/banners/RecommitmentDashBanner.tsx +++ b/frontend/src/components/profile/banners/RecommitmentDashBanner.tsx @@ -3,6 +3,7 @@ import { Banner } from '@/components/ui/Banner'; import type { RecommitmentCycle } from '@/common'; import { Transition } from '@headlessui/react'; import { useState } from 'react'; +import { format } from 'date-fns'; // TODO - make me look nice export const RecommitmentDashBanner = ({ @@ -34,13 +35,7 @@ export const RecommitmentDashBanner = ({ onClick={hideBanner} content={

- - {recommitment.year} CORE recommitment reminders have been sent to - members and supervisors.{' '} - - Returning members with supervisor approval will be marked as - Recommitted: {recommitment.year} in the coming weeks. Please monitor - their status for any needed follow-up and ParQ review. + {`The ${new Date(recommitment.endDate)?.getFullYear()} CORE recommitment period has begun and will end on ${format(new Date(recommitment?.endDate), 'MMMM do, yyyy') ?? ''}. Email reminders have been sent to active members and their supervisors. Returning members with supervisor approval will be marked as "Recommitted" in the coming weeks. Please monitor their status in case further communication is needed.`}

} onClose={hideBanner} diff --git a/frontend/src/components/recommitment/InitialRecommitmentDropdown.tsx b/frontend/src/components/recommitment/InitialRecommitmentDropdown.tsx index 74848074..f76938fd 100644 --- a/frontend/src/components/recommitment/InitialRecommitmentDropdown.tsx +++ b/frontend/src/components/recommitment/InitialRecommitmentDropdown.tsx @@ -7,7 +7,7 @@ export const InitialRecommitmentDropdown = ({ handleChange, }: { initialValue?: string; - program: Program; + program?: Program; handleChange: (v: string | undefined) => void; }) => { const getText = () => { diff --git a/frontend/src/components/recommitment/RecommitmentFormBase.tsx b/frontend/src/components/recommitment/RecommitmentFormBase.tsx index 34b33e40..6874aee2 100644 --- a/frontend/src/components/recommitment/RecommitmentFormBase.tsx +++ b/frontend/src/components/recommitment/RecommitmentFormBase.tsx @@ -23,7 +23,7 @@ interface StepIndicatorProps { } interface RecommitmentFormProps { - program: Program.BCWS | Program.EMCR | Program.ALL; + program?: Program; personnel: MemberProfile; onClose: () => void; } diff --git a/frontend/src/components/recommitment/SupervisorForm.tsx b/frontend/src/components/recommitment/SupervisorForm.tsx index f2f4120a..a32a4e31 100644 --- a/frontend/src/components/recommitment/SupervisorForm.tsx +++ b/frontend/src/components/recommitment/SupervisorForm.tsx @@ -5,13 +5,13 @@ interface SupervisorFormProps { firstName: string; lastName: string; email: string; - phone: string; + phone?: string; }; onUpdate: (data: { firstName: string; lastName: string; email: string; - phone: string; + phone?: string; }) => void; } diff --git a/frontend/src/components/table/body/TableBodyCell.tsx b/frontend/src/components/table/body/TableBodyCell.tsx index 1ade5344..6c69128b 100644 --- a/frontend/src/components/table/body/TableBodyCell.tsx +++ b/frontend/src/components/table/body/TableBodyCell.tsx @@ -72,6 +72,7 @@ export const TableBodyCell = ({ recommitmentStatus?: RecommitmentStatus; isRecommitmentCycleOpen?: boolean; }) => { + switch (cell.columnName) { case DashboardColumns.NAME: return ( @@ -84,13 +85,11 @@ export const TableBodyCell = ({ > {cell.value} - {status && status === Status.NEW && ( + {status && status === Status.NEW ? ( {StatusNames.NEW} - - )} - {/* Only show Active Persons recommitment status during recommitment period */} - {isRecommitmentCycleOpen && + ) : + isRecommitmentCycleOpen && recommitmentStatus && status === Status.ACTIVE && renderRecommitmentStatus(recommitmentStatus, isRecommitmentCycleOpen)} diff --git a/frontend/src/hooks/useMemberProfile.tsx b/frontend/src/hooks/useMemberProfile.tsx index 30486954..4db8d145 100644 --- a/frontend/src/hooks/useMemberProfile.tsx +++ b/frontend/src/hooks/useMemberProfile.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react'; -import type { MemberProfile, Personnel } from '@/common'; +import type { MemberProfile, Personnel, Recommitment } from '@/common'; import type { FormikValues } from 'formik'; import { useAxios } from './useAxios'; import { Program } from '@/common'; @@ -11,18 +11,22 @@ const useMemberProfile = (): { updatePersonnel: (person: FormikValues | Personnel) => Promise; loading: boolean; program?: Program; + recommitmentProgram?: Program; } => { const [personnel, setPersonnel] = useState(); const { AxiosPrivate } = useAxios(); const [refetch, setRefetch] = useState(false); const [loading, setIsLoading] = useState(false); const [program, setProgram] = useState(); + const [recommitmentProgram, setRecommitmentProgram] = useState(); const [openRecommitmentForm, setOpenRecommitmentForm] = useState(false); + const getProfileDetails = async () => { setIsLoading(true); try { const response = await AxiosPrivate.get(`/personnel`); response && setPersonnel({ ...response.data }); + // set program of personnel for personal data if (response?.data?.bcws && response?.data?.emcr) { setProgram(Program.ALL); } else if (response?.data?.emcr && !response?.data?.bcws) { @@ -30,6 +34,16 @@ const useMemberProfile = (): { } else if (response?.data?.bcws && !response?.data?.emcr) { setProgram(Program.BCWS); } + const bcwsRecommitment = response?.data?.recommitment?.find((itm: Recommitment) => itm.program === Program.BCWS); + const emcrRecommitment = response?.data?.recommitment?.find((itm: Recommitment) => itm.program === Program.EMCR); + // set program of recommitment for recommitment data + if (bcwsRecommitment && emcrRecommitment) { + setRecommitmentProgram(Program.ALL); + } else if (emcrRecommitment && !response?.data?.recommitment.bcws) { + setRecommitmentProgram(Program.EMCR); + } else if (bcwsRecommitment && !emcrRecommitment) { + setRecommitmentProgram(Program.BCWS); + } } catch (e) { console.log(e); } finally { @@ -62,6 +76,7 @@ const useMemberProfile = (): { loading, updatePersonnel, program, + recommitmentProgram }; }; diff --git a/frontend/src/pages/profile/MemberProfile.tsx b/frontend/src/pages/profile/MemberProfile.tsx index 2997c3d0..5b57fec7 100644 --- a/frontend/src/pages/profile/MemberProfile.tsx +++ b/frontend/src/pages/profile/MemberProfile.tsx @@ -18,6 +18,7 @@ const MemberProfile = () => { const { personnel, program, + recommitmentProgram, loading, updatePersonnel, openRecommitmentForm, @@ -120,11 +121,11 @@ const MemberProfile = () => { open={openRecommitmentForm} onClose={updatePersonnel} handleOpen={handleOpenRecommitmentForm} - title={`Confirm Recommitment Status for ${program === Program.ALL ? 'BCWS and EMCR' : program.toUpperCase()}`} + title={`Confirm Recommitment Status for ${recommitmentProgram === Program.ALL ? 'BCWS and EMCR' : recommitmentProgram?.toUpperCase()}`} style={'lg:w-2/3 xl:w-1/2'} > From 3a0d61dbe140d4083b26e835416a737381d702a6 Mon Sep 17 00:00:00 2001 From: Noel Feliciano Date: Sat, 18 Jan 2025 02:21:57 -0800 Subject: [PATCH 2/2] TC-907 --- .../recommitment/RecommitmentFormBase.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/recommitment/RecommitmentFormBase.tsx b/frontend/src/components/recommitment/RecommitmentFormBase.tsx index 6874aee2..485a76ac 100644 --- a/frontend/src/components/recommitment/RecommitmentFormBase.tsx +++ b/frontend/src/components/recommitment/RecommitmentFormBase.tsx @@ -248,11 +248,6 @@ export const RecommitmentFormBase = ({ onUpdate={setUnableToJoinReasons} key="unable" />, - , ]; default: return [ @@ -345,7 +340,10 @@ export const RecommitmentFormBase = ({ } } - if (currentComponentType === Assertions) { + if ( + currentComponentType === Assertions || + currentComponentType === UnableToJoin && recommitmentAnswer === 'no' + ) { setButtonLoading(true); handleSubmitRecommitment(); } @@ -460,7 +458,10 @@ export const RecommitmentFormBase = ({ const getButtonText = () => { const currentComponentType = currentComponent.type; - if (currentComponentType === Assertions) { + if ( + currentComponentType === Assertions || + currentComponentType === UnableToJoin && recommitmentAnswer === 'no' + ) { return 'Submit Decision'; } if (currentComponentType === ParQBase && currentParQStep === 3) {