From 8aa50b626b97d90464c21eae53fce36dc3b349e3 Mon Sep 17 00:00:00 2001 From: Jonathan Funk Date: Wed, 29 Jan 2025 13:57:52 -0800 Subject: [PATCH 1/9] prevent header status change without assigned officer --- .../complaints/details/complaint-header.tsx | 1 + .../modal/instances/change-status-modal.tsx | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/components/containers/complaints/details/complaint-header.tsx b/frontend/src/app/components/containers/complaints/details/complaint-header.tsx index 7807b99d1..174a31a3d 100644 --- a/frontend/src/app/components/containers/complaints/details/complaint-header.tsx +++ b/frontend/src/app/components/containers/complaints/details/complaint-header.tsx @@ -63,6 +63,7 @@ export const ComplaintHeader: FC = ({ complaint_identifier: id, complaint_type: complaintType, complaint_status: statusCode, + is_officer_assigned: officerAssigned === "Not Assigned" ? false : true, }, }), ); diff --git a/frontend/src/app/components/modal/instances/change-status-modal.tsx b/frontend/src/app/components/modal/instances/change-status-modal.tsx index 5498eb7cf..d493fc55f 100644 --- a/frontend/src/app/components/modal/instances/change-status-modal.tsx +++ b/frontend/src/app/components/modal/instances/change-status-modal.tsx @@ -65,6 +65,7 @@ export const ChangeStatusModal: FC = ({ close, submit, c }; const { title, description, complaint_identifier } = modalData; + const is_officer_assigned: boolean = modalData.is_officer_assigned; const handleSelectChange = (selectedValue: string) => { selectedStatus = selectedValue; @@ -114,6 +115,19 @@ export const ChangeStatusModal: FC = ({ close, submit, c )} + {!is_officer_assigned && ( + + + + + +
An officer must be assigned to the complaint before it can be closed.
+ +
+ )} = ({ close, submit, c Cancel From 0cb22ce42675b5d44c7ffbf79f7a79166f6d24b1 Mon Sep 17 00:00:00 2001 From: Jonathan Funk Date: Wed, 29 Jan 2025 14:45:39 -0800 Subject: [PATCH 2/9] auto assign as part of quickclose --- .../modal/instances/quick-close-modal.tsx | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/components/modal/instances/quick-close-modal.tsx b/frontend/src/app/components/modal/instances/quick-close-modal.tsx index be2535ee7..ad46a5cae 100644 --- a/frontend/src/app/components/modal/instances/quick-close-modal.tsx +++ b/frontend/src/app/components/modal/instances/quick-close-modal.tsx @@ -2,7 +2,7 @@ import { FC, memo, useEffect } from "react"; import { Modal, Spinner, Alert, Button } from "react-bootstrap"; import { Link } from "react-router-dom"; import { useAppSelector, useAppDispatch } from "@hooks/hooks"; -import { selectModalData, isLoading } from "@store/reducers/app"; +import { profileDisplayName, profileIdir, selectModalData, isLoading, userId } from "@store/reducers/app"; import { selectComplaint, refreshComplaints } from "@store/reducers/complaints"; import { setIsInEdit } from "@store/reducers/cases"; import { @@ -14,6 +14,7 @@ import { selectIsReviewRequired, selectReviewComplete, } from "@store/reducers/case-selectors"; +import { assignCurrentUserToComplaint } from "@store/reducers/officer"; import { HWCRComplaintAssessment } from "@components/containers/complaints/outcomes/hwcr-complaint-assessment"; import useValidateComplaint from "@/app/hooks/validate-complaint"; @@ -92,6 +93,9 @@ export const QuickCloseModal: FC = ({ const noteData = useAppSelector(selectSupplementalNote); const isReviewRequired = useAppSelector(selectIsReviewRequired); const reviewComplete = useAppSelector(selectReviewComplete); + const displayName = useAppSelector(profileDisplayName); + const idir = useAppSelector(profileIdir); + const userid = useAppSelector(userId); // Vars const { title, complaint_identifier } = modalData; @@ -129,6 +133,21 @@ export const QuickCloseModal: FC = ({ close={close} /> )} + {!loading && complaintData?.delegates?.every((delegate) => !delegate.isActive) && ( +
+ + + + {" "} + Without an officer assigned to this complaint, {displayName} will be assigned as part of the quick + close. + + +
+ )}
= ({ showHeader={false} handleSave={() => { submit(); + dispatch(assignCurrentUserToComplaint(userid, idir, complaint_identifier, complaint_type)); refreshComplaintsOnClose && dispatch(refreshComplaints(complaint_type)); }} handleClose={close} From 808293c37cf884d4bb52e4db69af784ec881e02a Mon Sep 17 00:00:00 2001 From: Jonathan Funk Date: Fri, 31 Jan 2025 10:48:23 -0800 Subject: [PATCH 3/9] cypress assign self on complaint status update --- .../e2e/change-complaint-status-details-view.cy.ts | 3 +++ frontend/cypress/support/commands.ts | 8 ++++++++ frontend/cypress/support/index.ts | 1 + 3 files changed, 12 insertions(+) diff --git a/frontend/cypress/e2e/change-complaint-status-details-view.cy.ts b/frontend/cypress/e2e/change-complaint-status-details-view.cy.ts index 5d6f41881..5e8910e15 100644 --- a/frontend/cypress/e2e/change-complaint-status-details-view.cy.ts +++ b/frontend/cypress/e2e/change-complaint-status-details-view.cy.ts @@ -35,9 +35,11 @@ describe("Complaint Change Status spec - Details View", () => { it("Changes status of closeable complaint to open, closed, and back to open", () => { if ("#hwcr-tab".includes(complaintTypes[index])) { cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076", true); + cy.assignSelfToComplaint(); fillInAssessmentSection(); } else { cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS, "23-006888", true); + cy.assignSelfToComplaint(); } cy.get("#details-screen-update-status-button").click({ force: true }); @@ -70,6 +72,7 @@ describe("Complaint Change Status spec - Details View", () => { it("Changes status of unclosable hwcr complaint from open to closed", () => { cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000078", true); + cy.assignSelfToComplaint(); cy.get("#details-screen-update-status-button").click({ force: true }); diff --git a/frontend/cypress/support/commands.ts b/frontend/cypress/support/commands.ts index 8f02d868c..926a3b56d 100644 --- a/frontend/cypress/support/commands.ts +++ b/frontend/cypress/support/commands.ts @@ -448,4 +448,12 @@ Cypress.Commands.add( }, ); +Cypress.Commands.add( + "assignSelfToComplaint", + () => { + cy.get("#details-screen-assign-button").click(); + cy.get("#self_assign_button").click(); + cy.waitForSpinner(); +}); + module.exports = {}; diff --git a/frontend/cypress/support/index.ts b/frontend/cypress/support/index.ts index 2d9e159b1..dc147fde5 100644 --- a/frontend/cypress/support/index.ts +++ b/frontend/cypress/support/index.ts @@ -31,5 +31,6 @@ declare namespace Cypress { fillInHWCSection(section: HwcSection): Chainable; validateHWCSection(section: HwcSection): Chainable; hasErrorMessage(inputs: Array, toastText?: string): Chainable; + assignSelfToComplaint(): Chainable; } } From 45498fd2a457a044145eff1ce8dcb1c22a9609c2 Mon Sep 17 00:00:00 2001 From: Jonathan Funk Date: Fri, 31 Jan 2025 10:55:13 -0800 Subject: [PATCH 4/9] fix always self assign bug --- .../src/app/components/modal/instances/quick-close-modal.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/components/modal/instances/quick-close-modal.tsx b/frontend/src/app/components/modal/instances/quick-close-modal.tsx index ad46a5cae..913f33e0a 100644 --- a/frontend/src/app/components/modal/instances/quick-close-modal.tsx +++ b/frontend/src/app/components/modal/instances/quick-close-modal.tsx @@ -159,7 +159,9 @@ export const QuickCloseModal: FC = ({ showHeader={false} handleSave={() => { submit(); - dispatch(assignCurrentUserToComplaint(userid, idir, complaint_identifier, complaint_type)); + if (complaintData?.delegates?.every((delegate) => !delegate.isActive)) { + dispatch(assignCurrentUserToComplaint(userid, idir, complaint_identifier, complaint_type)); + } refreshComplaintsOnClose && dispatch(refreshComplaints(complaint_type)); }} handleClose={close} From 5f4fbf64eef53620cbcde57453527a56c8a25bcd Mon Sep 17 00:00:00 2001 From: Jonathan Funk Date: Fri, 31 Jan 2025 10:56:14 -0800 Subject: [PATCH 5/9] wording tweak --- .../src/app/components/modal/instances/quick-close-modal.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/app/components/modal/instances/quick-close-modal.tsx b/frontend/src/app/components/modal/instances/quick-close-modal.tsx index 913f33e0a..fb4a27faa 100644 --- a/frontend/src/app/components/modal/instances/quick-close-modal.tsx +++ b/frontend/src/app/components/modal/instances/quick-close-modal.tsx @@ -142,8 +142,7 @@ export const QuickCloseModal: FC = ({ {" "} - Without an officer assigned to this complaint, {displayName} will be assigned as part of the quick - close. + Without an officer assigned to this complaint {displayName} will be assigned as part of the quick close.
From c6d2a4e6070092b5b6e3fcb51a685d44b0f144fd Mon Sep 17 00:00:00 2001 From: Jonathan Funk Date: Fri, 31 Jan 2025 11:01:28 -0800 Subject: [PATCH 6/9] fix boolean code smell --- .../containers/complaints/details/complaint-header.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app/components/containers/complaints/details/complaint-header.tsx b/frontend/src/app/components/containers/complaints/details/complaint-header.tsx index 174a31a3d..cb75d13ff 100644 --- a/frontend/src/app/components/containers/complaints/details/complaint-header.tsx +++ b/frontend/src/app/components/containers/complaints/details/complaint-header.tsx @@ -63,7 +63,7 @@ export const ComplaintHeader: FC = ({ complaint_identifier: id, complaint_type: complaintType, complaint_status: statusCode, - is_officer_assigned: officerAssigned === "Not Assigned" ? false : true, + is_officer_assigned: officerAssigned !== "Not Assigned", }, }), ); From ad22c1660c1915561017fba9672df6931c8fca25 Mon Sep 17 00:00:00 2001 From: Jonathan Funk Date: Mon, 3 Feb 2025 10:26:18 -0800 Subject: [PATCH 7/9] refer to close status prop in warnings --- .../modal/instances/change-status-modal.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/components/modal/instances/change-status-modal.tsx b/frontend/src/app/components/modal/instances/change-status-modal.tsx index d493fc55f..9eb0ec518 100644 --- a/frontend/src/app/components/modal/instances/change-status-modal.tsx +++ b/frontend/src/app/components/modal/instances/change-status-modal.tsx @@ -32,7 +32,7 @@ export const ChangeStatusModal: FC = ({ close, submit, c const dispatch = useAppDispatch(); let [status, setStatus] = useState(""); - let selectedStatus = ""; + const [selectedStatus, setSelectedStatus] = useState(""); useEffect(() => { if (status.length > 1) { @@ -68,7 +68,7 @@ export const ChangeStatusModal: FC = ({ close, submit, c const is_officer_assigned: boolean = modalData.is_officer_assigned; const handleSelectChange = (selectedValue: string) => { - selectedStatus = selectedValue; + setSelectedStatus(selectedValue); }; const validationResults = useValidateComplaint(); @@ -115,7 +115,7 @@ export const ChangeStatusModal: FC = ({ close, submit, c )} - {!is_officer_assigned && ( + {!is_officer_assigned && selectedStatus === "CLOSED" && ( = ({ close, submit, c active={!statusChangeDisabledInd && is_officer_assigned} id="update_complaint_status_button" onClick={handleSubmit} - className={!statusChangeDisabledInd && is_officer_assigned ? "" : "inactive-button"} - disabled={!is_officer_assigned} + className={ + !statusChangeDisabledInd && (is_officer_assigned || selectedStatus === "OPEN") ? "" : "inactive-button" + } + disabled={!is_officer_assigned && selectedStatus === "CLOSED"} > Update From e8deb0e056dde03a4400b391f813f8e28c2f7509 Mon Sep 17 00:00:00 2001 From: Jonathan Funk Date: Mon, 3 Feb 2025 14:44:37 -0800 Subject: [PATCH 8/9] assessment officer used for auto assign --- .../outcomes/hwcr-complaint-assessment.tsx | 23 ++++++++++++++++++- .../modal/instances/quick-close-modal.tsx | 14 ++++------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/frontend/src/app/components/containers/complaints/outcomes/hwcr-complaint-assessment.tsx b/frontend/src/app/components/containers/complaints/outcomes/hwcr-complaint-assessment.tsx index 529c28aa7..2fbd1f2e2 100644 --- a/frontend/src/app/components/containers/complaints/outcomes/hwcr-complaint-assessment.tsx +++ b/frontend/src/app/components/containers/complaints/outcomes/hwcr-complaint-assessment.tsx @@ -10,6 +10,7 @@ import { selectComplaintLargeCarnivoreInd, selectLinkedComplaints, selectComplaintViewMode, + selectComplaint, } from "@store/reducers/complaints"; import { selectAssessmentCat1Dropdown, @@ -39,6 +40,8 @@ import { OptionLabels } from "@constants/option-labels"; import { HWCRComplaintAssessmentLinkComplaintSearch } from "./hwcr-complaint-assessment-link-complaint-search"; import { CompRadioGroup } from "@/app/components/common/comp-radiogroup"; import useValidateComplaint from "@hooks/validate-complaint"; +import { assignComplaintToOfficer } from "@store/reducers/officer"; +import { Officer } from "@/app/types/person/person"; type Props = { id: string; @@ -65,6 +68,7 @@ export const HWCRComplaintAssessment: FC = ({ const [editable, setEditable] = useState(true); const [validateOnChange, setValidateOnChange] = useState(false); const [selectedContacted, setSelectedContacted] = useState("No"); + const [selectedOfficerData, setSelectedOfficerData] = useState(); const [selectedAttended, setSelectedAttended] = useState("No"); const [selectedLocation, setSelectedLocation] = useState