diff --git a/frontend/cypress/e2e/complaint-filters-ceeb.cy.ts b/frontend/cypress/e2e/complaint-filters-ceeb.cy.ts index 111c08f78..3cd6a93d9 100644 --- a/frontend/cypress/e2e/complaint-filters-ceeb.cy.ts +++ b/frontend/cypress/e2e/complaint-filters-ceeb.cy.ts @@ -10,17 +10,6 @@ describe("Verify CEEB specific search filters work", () => { cy.kcLogout().kcLogin(Roles.CEEB); }); - function needsDecision() { - let needsDecision = false; - cy.get("#ceeb-decision").then((decisionWrapper) => { - // If the action taken input is on the page, a decision needs to be made - if (decisionWrapper.find("#outcome-decision-action-taken").length > 0) { - needsDecision = true; - } - }); - return needsDecision; - } - it.only("allows filtering of complaints by Action Taken", function () { // Navigate to the complaint list const complaintWithActionTakenID = "23-030990"; @@ -30,22 +19,19 @@ describe("Verify CEEB specific search filters work", () => { cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS, complaintWithActionTakenID, true); // If the action taken input is available then the complaint does not yet have a decision made on it. // Set an action taken so that the filter will have results to return. - if (needsDecision()) { - cy.selectItemById("outcome-decision-schedule-sector", "Other"); - cy.selectItemById("outcome-decision-sector-category", "None"); - cy.selectItemById("outcome-decision-discharge", "Pesticides"); - cy.selectItemById("outcome-decision-action-taken", actionTaken); - cy.selectItemById("outcome-decision-lead-agency", "Other"); - cy.enterDateTimeInDatePicker("outcome-decision-outcome-date", "01"); - // If the complaint is not assigned to anyone, assign it to self - if (cy.get("#comp-details-assigned-officer-name-text-id").contains("Not Assigned")) { - cy.get("#details-screen-assign-button").should("exist").click(); - cy.get("#self_assign_button").should("exist").click(); + cy.get("#ceeb-decision").then((decisionWrapper) => { + // If the edit button is on the page, a decision needs to be made + if (!decisionWrapper.find("#decision-edit-button").length) { + cy.selectItemById("outcome-decision-schedule-sector", "Other"); + cy.selectItemById("outcome-decision-sector-category", "None"); + cy.selectItemById("outcome-decision-discharge", "Pesticides"); + cy.selectItemById("outcome-decision-action-taken", actionTaken); + cy.selectItemById("outcome-decision-lead-agency", "Other"); + cy.enterDateTimeInDatePicker("outcome-decision-outcome-date", "01"); + cy.get("#ceeb-decision > .card-body > .comp-details-form-buttons > #outcome-decision-save-button").click(); + cy.contains("div", "Decision added").should("exist"); } - cy.get(".modal").should("not.exist"); // Ensure that the quick assign modal has closed - cy.get("#ceeb-decision > .card-body > .comp-details-form-buttons > #outcome-decision-save-button").click(); - cy.contains("div", "Decision added").should("exist"); - } + }); // Return to the complaints view cy.get("#complaints-link").click(); diff --git a/frontend/src/app/components/containers/complaints/outcomes/ceeb/ceeb-decision/decision-form.tsx b/frontend/src/app/components/containers/complaints/outcomes/ceeb/ceeb-decision/decision-form.tsx index d0de0cc0c..3dad31d95 100644 --- a/frontend/src/app/components/containers/complaints/outcomes/ceeb/ceeb-decision/decision-form.tsx +++ b/frontend/src/app/components/containers/complaints/outcomes/ceeb/ceeb-decision/decision-form.tsx @@ -19,21 +19,11 @@ import { CompInput } from "../../../../../common/comp-input"; import { openModal } from "../../../../../../store/reducers/app"; import { CANCEL_CONFIRM } from "../../../../../../types/modal/modal-types"; import { getCaseFile, upsertDecisionOutcome } from "../../../../../../store/reducers/case-thunks"; -import { - assignComplaintToOfficer, - selectOfficersByAgency, - selectOfficerListByAgency, -} from "../../../../../../store/reducers/officer"; import { selectCaseId } from "../../../../../../store/reducers/case-selectors"; import { UUID } from "crypto"; -import { getComplaintById, selectComplaintCallerInformation } from "../../../../../../store/reducers/complaints"; -import { ToggleError } from "../../../../../../common/toast"; - -import COMPLAINT_TYPES from "../../../../../../types/app/complaint-types"; import { ValidationTextArea } from "../../../../../../common/validation-textarea"; type props = { - officerAssigned: string | null; leadIdentifier: string; toggleEdit: Function; //-- properties @@ -51,7 +41,6 @@ type props = { }; export const DecisionForm: FC = ({ - officerAssigned, leadIdentifier, toggleEdit, //-- @@ -71,6 +60,7 @@ export const DecisionForm: FC = ({ //-- select data from redux const caseId = useAppSelector(selectCaseId) as UUID; + const current_user = useAppSelector((state) => state.app.profile.idir); //-- drop-downs const dischargesOptions = useAppSelector(selectDischargeDropdown); @@ -79,9 +69,6 @@ export const DecisionForm: FC = ({ const schedulesOptions = useAppSelector(selectScheduleDropdown); const decisionTypeOptions = useAppSelector(selectDecisionTypeDropdown); const leadAgencyOptions = useAppSelector(selectLeadAgencyDropdown); - const { ownedByAgencyCode } = useAppSelector(selectComplaintCallerInformation); - const officerOptions = useAppSelector(selectOfficerListByAgency); - const officersInAgencyList = useAppSelector(selectOfficersByAgency(ownedByAgencyCode?.agency)); const scheduleSectorType = useAppSelector(selectScheduleSectorXref); //-- error messgaes @@ -92,7 +79,6 @@ export const DecisionForm: FC = ({ const [dateActionTakenErrorMessage, setDateActionTakenErrorMessage] = useState(""); const [leadAgencyErrorMessage, setLeadAgencyErrorMessage] = useState(""); const [inspectionNumberErrorMessage, setInspectionNumberErrorMessage] = useState(""); - const [assignedToErrorMessage, setAssignedToErrorMessage] = useState(""); const [actionTakenErrorMessage, setActionTakenErrorMessage] = useState(""); //-- component data @@ -105,20 +91,13 @@ export const DecisionForm: FC = ({ rationale, inspectionNumber, leadAgency, - assignedTo: officerAssigned ?? "", + assignedTo, actionTaken, actionTakenDate, }); const [sectorList, setSectorList] = useState>(); - useEffect(() => { - if (officerAssigned) { - setData({ ...data, assignedTo: officerAssigned }); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [officerAssigned]); - useEffect(() => { if (sector && schedule) { let options = scheduleSectorType @@ -129,11 +108,12 @@ export const DecisionForm: FC = ({ }); setSectorList(options); } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [officerAssigned]); + }, [sector, schedule, scheduleSectorType]); + //-- update the decision state by property const updateModel = (property: string, value: string | Date | undefined) => { const model = { ...data, [property]: value }; + setData(model); }; @@ -176,24 +156,11 @@ export const DecisionForm: FC = ({ result = decisionTypeOptions.find((item) => item.value === actionTaken); break; } - - case "assignedTo": { - const { assignedTo } = data; - result = officerOptions.find((item) => item.value === assignedTo); - break; - } } return !result ? null : result; }; - //-- when setting the assignment this should also update the assignment - //-- of the complaint to the officer being selected in the decision - const updateAssignment = (value?: string) => { - //-- need to get the officer_guid instead of the person - updateModel("assignedTo", value); - }; - const handleRationaleChange = (value: string) => { updateModel("rationale", value.trim()); }; @@ -217,7 +184,13 @@ export const DecisionForm: FC = ({ const handleActionTakenChange = (value: string) => { //-- if the action taken changes make sure to clear the //-- lead agency and inspection number - const update = { ...data, actionTaken: value, leadAgency: undefined, inspectionNumber: undefined }; + const update = { + ...data, + actionTaken: value, + assignedTo: current_user, + leadAgency: undefined, + inspectionNumber: undefined, + }; setData(update); }; @@ -260,7 +233,6 @@ export const DecisionForm: FC = ({ setSectorErrorMessage(""); setDischargeErrorMessage(""); setActionTakenErrorMessage(""); - setAssignedToErrorMessage(""); setDateActionTakenErrorMessage(""); setLeadAgencyErrorMessage(""); setInspectionNumberErrorMessage(""); @@ -273,25 +245,6 @@ export const DecisionForm: FC = ({ if (isValid()) { dispatch(upsertDecisionOutcome(identifier, data)).then(async (response) => { if (response === "success") { - //-- update the assignment of the complaint to the selected officer - const { assignedTo } = data; - if (assignedTo && officersInAgencyList) { - const officerAssignedObj = officersInAgencyList.find((officer) => officer.auth_user_guid === assignedTo); - - if (officerAssignedObj?.person_guid) { - const result = await dispatch( - assignComplaintToOfficer(leadIdentifier, officerAssignedObj.person_guid.person_guid), - ); - - if (result) { - //-- update the complaint - dispatch(getComplaintById(leadIdentifier, COMPLAINT_TYPES.ERS)); - } else { - ToggleError("Error, unable to to assign officer to complaint"); - } - } - } - dispatch(getCaseFile(leadIdentifier)); if (id !== undefined) { @@ -325,32 +278,14 @@ export const DecisionForm: FC = ({ }; const _isActionValid = (data: Decision, _isValid: boolean): boolean => { - if (data.actionTaken && (!data.actionTakenDate || !data.assignedTo)) { - if (!data.actionTakenDate) { - setDateActionTakenErrorMessage("Date required when action taken selected"); - _isValid = false; - } - - if (!data.assignedTo) { - setAssignedToErrorMessage("Assigned to required when action taken selected"); - _isValid = false; - } + if (data.actionTaken && !data.actionTakenDate) { + setDateActionTakenErrorMessage("Date required when action taken selected"); + _isValid = false; } - return _isValid; - }; - - const _isAssignedToValid = (data: Decision, _isValid: boolean): boolean => { - if (data.assignedTo && (!data.actionTaken || !data.actionTakenDate)) { - if (!data.actionTakenDate) { - setDateActionTakenErrorMessage("Date required when action taken selected"); - _isValid = false; - } - - if (!data.actionTaken) { - setActionTakenErrorMessage("Action taken required when assigned to is selected"); - _isValid = false; - } + if (data.actionTakenDate && !data.actionTaken) { + setActionTakenErrorMessage("Action taken required when date is selected"); + _isValid = false; } return _isValid; @@ -373,7 +308,6 @@ export const DecisionForm: FC = ({ } _isValid = _isActionValid(data, _isValid); - _isValid = _isAssignedToValid(data, _isValid); return _isValid; }; @@ -556,27 +490,6 @@ export const DecisionForm: FC = ({ /> -
- -
- { - updateAssignment(evt?.value); - }} - value={getValue("assignedTo")} - /> -
-
= ({ - id, schedule, sector, discharge, @@ -36,7 +34,6 @@ export const DecisionItem: FC = ({ rationale, leadAgency, inspectionNumber, - assignedTo, actionTaken, actionTakenDate, }) => { @@ -48,7 +45,6 @@ export const DecisionItem: FC = ({ const scheduleSectorsOptions = useAppSelector(selectSectorDropdown); const decisionTypeOptions = useAppSelector(selectDecisionTypeDropdown); const agencyOptions = useAppSelector(selectLeadAgencyDropdown); - const officerOptions = useAppSelector(selectOfficerListByAgency); const getValue = (property: string): Option | undefined | null => { let result: Option | undefined; @@ -90,11 +86,6 @@ export const DecisionItem: FC = ({ result = decisionTypeOptions.find((item) => item.value === actionTaken); break; } - - case "assignedTo": { - result = officerOptions.find((item) => item.value === assignedTo); - break; - } } return !result ? null : result; @@ -139,11 +130,6 @@ export const DecisionItem: FC = ({
Rationale
{rationale}
-
-
Assigned to
-
{getValue("assignedTo")?.label}
-
-
Date action taken
{actionTakenDate !== null && formatDate(new Date(actionTakenDate).toString())}
diff --git a/frontend/src/app/components/containers/complaints/outcomes/ceeb/ceeb-decision/decision.tsx b/frontend/src/app/components/containers/complaints/outcomes/ceeb/ceeb-decision/decision.tsx index c0fd9f548..176102345 100644 --- a/frontend/src/app/components/containers/complaints/outcomes/ceeb/ceeb-decision/decision.tsx +++ b/frontend/src/app/components/containers/complaints/outcomes/ceeb/ceeb-decision/decision.tsx @@ -8,7 +8,6 @@ import { setIsInEdit } from "../../../../../../store/reducers/cases"; import { DecisionForm } from "./decision-form"; import { DecisionItem } from "./decision-item"; import { BsExclamationCircleFill } from "react-icons/bs"; -import { assignedOfficerAuthId } from "../../../../../../store/reducers/complaints"; export const CeebDecision: FC = () => { const { id = "" } = useParams(); @@ -17,9 +16,6 @@ export const CeebDecision: FC = () => { //-- select the decision const data = useAppSelector(selectCaseDecision); - //-- get the officer assigned to the complaint - const officerAssigned = useAppSelector(assignedOfficerAuthId); - const isInEdit = useAppSelector((state) => state.cases.isInEdit); const [editable, setEditable] = useState(true); const showSectionErrors = isInEdit.showSectionErrors; @@ -52,6 +48,7 @@ export const CeebDecision: FC = () => { {!editable && (