Skip to content

Commit

Permalink
bug: CE-553 Resolve the issue of GUID in the officer field (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitri-korin-bcps authored Apr 25, 2024
1 parent 56a0233 commit da2d676
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Option from "../../../../types/app/option";
import { Button } from "react-bootstrap";
import { Officer } from "../../../../types/person/person";
import { useAppDispatch, useAppSelector } from "../../../../hooks/hooks";
import { selectOfficersByAgency, selectOfficers } from "../../../../store/reducers/officer";
import { selectOfficersByAgency } from "../../../../store/reducers/officer";
import {
getComplaintById,
selectComplaint,
Expand Down Expand Up @@ -62,7 +62,6 @@ export const HWCRComplaintAssessment: FC = () => {
const { id = "", complaintType = "" } = useParams<ComplaintParams>();
const { ownedByAgencyCode } = useAppSelector(selectComplaintCallerInformation);
const officersInAgencyList = useAppSelector(selectOfficersByAgency(ownedByAgencyCode?.agency));
const officerList = useAppSelector(selectOfficers);

const assignableOfficers: Option[] =
officersInAgencyList !== null
Expand Down Expand Up @@ -112,7 +111,7 @@ export const HWCRComplaintAssessment: FC = () => {
if (complaintData) {
const officer = getSelectedOfficer(assignableOfficers, personGuid, complaintData);
setSelectedOfficer(officer);
dispatch(getAssessment(complaintData.id, officerList ?? undefined));
dispatch(getAssessment(complaintData.id));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [complaintData]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Option from "../../../../types/app/option";
import { Button } from "react-bootstrap";
import { Officer } from "../../../../types/person/person";
import { useAppDispatch, useAppSelector } from "../../../../hooks/hooks";
import { selectOfficersByAgency, selectOfficers } from "../../../../store/reducers/officer";
import { selectOfficersByAgency } from "../../../../store/reducers/officer";
import {
getComplaintById,
selectComplaint,
Expand Down Expand Up @@ -75,7 +75,6 @@ export const HWCRComplaintPrevention: FC = () => {
const preventionTypeList = useAppSelector(selectPreventionTypeCodeDropdown);
const { personGuid } = useAppSelector(selectComplaintHeader(complaintType));
const assigned = useAppSelector(selectComplaintAssignedBy);
const officerList = useAppSelector(selectOfficers);

useEffect(() => {
if (id && (!complaintData || complaintData.id !== id)) {
Expand All @@ -87,7 +86,7 @@ export const HWCRComplaintPrevention: FC = () => {
if (complaintData) {
const officer = getSelectedOfficer(assignableOfficers, personGuid, complaintData);
setSelectedOfficer(officer);
dispatch(getPrevention(complaintData.id, officerList ?? undefined));
dispatch(getPrevention(complaintData.id));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [complaintData]);
Expand Down
10 changes: 4 additions & 6 deletions frontend/src/app/store/reducers/case-thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@ export const getCaseFile =

//-- assessment thunks
export const getAssessment =
(complaintIdentifier?: string, officerList?: Officer[]): AppThunk =>
(complaintIdentifier?: string): AppThunk =>
async (dispatch, getState) => {
const {
officers: { officers },
} = getState();
const officerListParam = officers ?? officerList;
const parameters = generateApiParameters(`${config.API_BASE_URL}/v1/case/${complaintIdentifier}`);
await get<CaseFileDto>(dispatch, parameters).then(async (res) => {
const updatedAssessmentData = await parseAssessmentResponse(res, officerListParam);
const updatedAssessmentData = await parseAssessmentResponse(res, officers);
dispatch(setCaseId(res.caseIdentifier));
dispatch(setAssessment({ assessment: updatedAssessmentData }));
dispatch(setIsReviewedRequired(res.isReviewRequired));
Expand Down Expand Up @@ -258,15 +257,14 @@ const parseAssessmentResponse = async (

//-- prevention and education thunks
export const getPrevention =
(complaintIdentifier?: string, officerList?: Officer[]): AppThunk =>
(complaintIdentifier?: string): AppThunk =>
async (dispatch, getState) => {
const {
officers: { officers },
} = getState();
const officerListParam = officers ?? officerList;
const parameters = generateApiParameters(`${config.API_BASE_URL}/v1/case/${complaintIdentifier}`);
await get<CaseFileDto>(dispatch, parameters).then(async (res) => {
const updatedPreventionData = await parsePreventionResponse(res, officerListParam);
const updatedPreventionData = await parsePreventionResponse(res, officers);
dispatch(setPrevention({ prevention: updatedPreventionData }));
});
};
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const persistConfig = {
key: "enforcement",
storage,
blacklist: ["app"],
whitelist: ["codeTables"],
version: 6, // This needs to be incremented every time a new migration is added
whitelist: ["codeTables", "officers"],
version: 6, // This needs to be incremented every time a new migration is added
debug: true,
migrate: createMigrate(migration, { debug: false }),
};
Expand Down

0 comments on commit da2d676

Please sign in to comment.