Skip to content

Commit

Permalink
chore: CE-590 standardized on actor guid (#706)
Browse files Browse the repository at this point in the history
Signed-off-by: OMPRAKASH MISHRA <[email protected]>
Co-authored-by: gregorylavery <[email protected]>
Co-authored-by: Barrett Falk <[email protected]>
Co-authored-by: dmitri-korin-bcps <[email protected]>
Co-authored-by: Mike <[email protected]>
Co-authored-by: Mike Sears <[email protected]>
Co-authored-by: jeznorth <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: afwilcox <[email protected]>
Co-authored-by: Ryan Rondeau <[email protected]>
Co-authored-by: jon-funk <[email protected]>
Co-authored-by: Mike Vesprini <[email protected]>
Co-authored-by: Om Mishra <[email protected]>
  • Loading branch information
13 people authored Oct 21, 2024
1 parent 4074f58 commit 5e692c6
Show file tree
Hide file tree
Showing 22 changed files with 176 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
selectGirTypeCodeDropdown,
selectComplaintReceivedMethodDropdown,
} from "../../../store/reducers/code-table";
import { selectOfficersByAgencyDropdownUsingPersonGuid } from "../../../store/reducers/officer";
import { selectDecisionTypeDropdown } from "../../../store/reducers/code-table-selectors";
import { selectOfficersByAgencyDropdown } from "../../../store/reducers/officer";
import COMPLAINT_TYPES from "../../../types/app/complaint-types";
import DatePicker from "react-datepicker";
import { CompSelect } from "../../common/comp-select";
Expand Down Expand Up @@ -50,7 +50,7 @@ export const ComplaintFilter: FC<Props> = ({ type }) => {
} = useContext(ComplaintFilterContext);

const agency = UserService.getUserAgency();
let officersByAgency = useAppSelector(selectOfficersByAgencyDropdown(agency));
let officersByAgency = useAppSelector(selectOfficersByAgencyDropdownUsingPersonGuid(agency));
if (officersByAgency && officersByAgency[0]?.value !== "Unassigned") {
officersByAgency.unshift({ value: "Unassigned", label: "Unassigned" });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +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, selectOfficersByAgencyDropdown } from "../../../../../../store/reducers/officer";
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";
Expand Down Expand Up @@ -76,7 +80,8 @@ export const DecisionForm: FC<props> = ({
const decisionTypeOptions = useAppSelector(selectDecisionTypeDropdown);
const leadAgencyOptions = useAppSelector(selectLeadAgencyDropdown);
const { ownedByAgencyCode } = useAppSelector(selectComplaintCallerInformation);
const officerOptions = useAppSelector(selectOfficersByAgencyDropdown(ownedByAgencyCode?.agency));
const officerOptions = useAppSelector(selectOfficerListByAgency);
const officersInAgencyList = useAppSelector(selectOfficersByAgency(ownedByAgencyCode?.agency));
const scheduleSectorType = useAppSelector(selectScheduleSectorXref);

//-- error messgaes
Expand Down Expand Up @@ -270,14 +275,20 @@ export const DecisionForm: FC<props> = ({
if (response === "success") {
//-- update the assignment of the complaint to the selected officer
const { assignedTo } = data;
if (assignedTo) {
const result = await dispatch(assignComplaintToOfficer(leadIdentifier, assignedTo));

if (result) {
//-- update the complaint
dispatch(getComplaintById(leadIdentifier, COMPLAINT_TYPES.ERS));
} else {
ToggleError("Error, unable to to assign officer to complaint");
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");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
selectScheduleDropdown,
selectDecisionTypeDropdown,
} from "../../../../../../store/reducers/code-table-selectors";
import { selectOfficersDropdown } from "../../../../../../store/reducers/officer";
import { selectOfficerListByAgency } from "../../../../../../store/reducers/officer";
import Option from "../../../../../../types/app/option";
import { CASE_ACTION_CODE } from "../../../../../../constants/case_actions";

Expand Down Expand Up @@ -48,7 +48,7 @@ export const DecisionItem: FC<props> = ({
const scheduleSectorsOptions = useAppSelector(selectSectorDropdown);
const decisionTypeOptions = useAppSelector(selectDecisionTypeDropdown);
const agencyOptions = useAppSelector(selectLeadAgencyDropdown);
const officerOptions = useAppSelector(selectOfficersDropdown(true));
const officerOptions = useAppSelector(selectOfficerListByAgency);

const getValue = (property: string): Option | undefined | null => {
let result: Option | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { setIsInEdit } from "../../../../../../store/reducers/cases";
import { DecisionForm } from "./decision-form";
import { DecisionItem } from "./decision-item";
import { BsExclamationCircleFill } from "react-icons/bs";
import { selectComplaintAssignedBy } from "../../../../../../store/reducers/complaints";
import { assignedOfficerAuthId } from "../../../../../../store/reducers/complaints";

export const CeebDecision: FC = () => {
const { id = "" } = useParams<ComplaintParams>();
Expand All @@ -18,7 +18,7 @@ export const CeebDecision: FC = () => {
const data = useAppSelector(selectCaseDecision);

//-- get the officer assigned to the complaint
const officerAssigned = useAppSelector(selectComplaintAssignedBy);
const officerAssigned = useAppSelector(assignedOfficerAuthId);

const isInEdit = useAppSelector((state) => state.cases.isInEdit);
const [editable, setEditable] = useState(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { FC, useEffect, useState } from "react";
import Option from "../../../../types/app/option";
import { Button, Card } from "react-bootstrap";
import { Officer } from "../../../../types/person/person";
import { useAppDispatch, useAppSelector } from "../../../../hooks/hooks";
import { selectOfficersByAgency } from "../../../../store/reducers/officer";
import { selectOfficerListByAgency, selectOfficersByAgency } from "../../../../store/reducers/officer";
import {
getComplaintById,
selectComplaint,
Expand Down Expand Up @@ -63,6 +62,7 @@ export const HWCRComplaintAssessment: FC = () => {
const { ownedByAgencyCode } = useAppSelector(selectComplaintCallerInformation);
const officersInAgencyList = useAppSelector(selectOfficersByAgency(ownedByAgencyCode?.agency));
const cases = useAppSelector((state) => state.cases);
const assignableOfficers = useAppSelector(selectOfficerListByAgency);

const hasAssessment = Object.keys(cases.assessment).length > 0;
const showSectionErrors = (!hasAssessment || editable) && cases.isInEdit.showSectionErrors;
Expand All @@ -73,13 +73,6 @@ export const HWCRComplaintAssessment: FC = () => {
} else dispatch(setIsInEdit({ assessment: editable }));
}, [editable, hasAssessment]);

const assignableOfficers: Option[] =
officersInAgencyList !== null
? officersInAgencyList.map((officer: Officer) => ({
value: officer.person_guid.person_guid,
label: `${officer.person_guid.last_name}, ${officer.person_guid.first_name}`,
}))
: [];
const handleDateChange = (date: Date | null) => {
setSelectedDate(date);
};
Expand Down Expand Up @@ -189,7 +182,7 @@ export const HWCRComplaintAssessment: FC = () => {
.map((item) => {
return {
label: `${item.person_guid?.last_name}, ${item.person_guid?.first_name}`,
value: assigned,
value: item.auth_user_guid,
} as Option;
});
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Button, Card } from "react-bootstrap";
import { ToastContainer } from "react-toastify";

import { useAppDispatch, useAppSelector } from "../../../../../hooks/hooks";
import { selectOfficersByAgency } from "../../../../../store/reducers/officer";
import { selectOfficerListByAgency, selectOfficersByAgency } from "../../../../../store/reducers/officer";
import { selectEquipmentDropdown, selectTrapEquipment } from "../../../../../store/reducers/code-table";
import {
getComplaintById,
Expand Down Expand Up @@ -41,7 +41,7 @@ export const EquipmentForm: FC<EquipmentFormProps> = ({ equipment, assignedOffic
const [type, setType] = useState<Option>();
const [dateSet, setDateSet] = useState<Date>(new Date());
const [dateRemoved, setDateRemoved] = useState<Date>();
const [officerSet, setOfficerSet] = useState<Option>();
const [officerSet, setOfficerSet] = useState<Option | undefined>();
const [officerRemoved, setOfficerRemoved] = useState<Option>();
const [address, setAddress] = useState<string | undefined>("");
const [xCoordinate, setXCoordinate] = useState<string | undefined>("");
Expand All @@ -67,24 +67,26 @@ export const EquipmentForm: FC<EquipmentFormProps> = ({ equipment, assignedOffic
const officersInAgencyList = useAppSelector(selectOfficersByAgency(ownedByAgencyCode?.agency));
const equipmentDropdownOptions = useAppSelector(selectEquipmentDropdown);
const trapEquipment = useAppSelector(selectTrapEquipment);
const assignableOfficers = useAppSelector(selectOfficerListByAgency);

const isInEdit = useAppSelector((state) => state.cases.isInEdit);
const showSectionErrors = isInEdit.showSectionErrors;

const assignableOfficers: Option[] =
officersInAgencyList !== null
? officersInAgencyList.map((officer: Officer) => ({
value: officer.person_guid.person_guid,
label: `${officer.person_guid.last_name}, ${officer.person_guid.first_name}`,
}))
: [];

useEffect(() => {
if (assignedOfficer) {
const setOfficer = getSelectedItem(assignedOfficer, assignableOfficers);
setOfficerSet(setOfficer);
if (assignedOfficer && officersInAgencyList) {
const officerAssigned: any = officersInAgencyList
.filter((officer) => officer.person_guid.person_guid === assignedOfficer)
.map((item) => {
return {
label: `${item.person_guid?.last_name}, ${item.person_guid?.first_name}`,
value: item.auth_user_guid,
} as Option;
});
if (officerAssigned.length === 1) {
setOfficerSet(officerAssigned[0]);
}
}
}, [complaintData]);
}, [assignedOfficer]);

useEffect(() => {
if (id && (!complaintData || complaintData.id !== id)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { formatDate } from "../../../../../common/methods";

import { DeleteConfirmModal } from "../../../../modal/instances/delete-confirm-modal";
import { EquipmentDetailsDto } from "../../../../../types/app/case-files/equipment-details";
import { selectOfficerByPersonGuid } from "../../../../../store/reducers/officer";
import { selectOfficerByAuthUserGuid } from "../../../../../store/reducers/officer";
import { useAppDispatch, useAppSelector } from "../../../../../hooks/hooks";

import Option from "../../../../../types/app/option";
Expand Down Expand Up @@ -57,9 +57,8 @@ export const EquipmentItem: FC<EquipmentItemProps> = ({ equipment, isEditDisable
(action) => action.actionCode === CASE_ACTION_CODE.REMEQUIPMT,
)?.date;
const removedEquipmentDate = removedEquipmentDateString ? new Date(new Date(removedEquipmentDateString)) : null;

const setEquipmentOfficer = useAppSelector(selectOfficerByPersonGuid(`${setEquipmentActor}`));
const removedEquipmentOfficer = useAppSelector(selectOfficerByPersonGuid(`${removedEquipmentActor}`));
const setEquipmentOfficer = useAppSelector(selectOfficerByAuthUserGuid(`${setEquipmentActor}`));
const removedEquipmentOfficer = useAppSelector(selectOfficerByAuthUserGuid(`${removedEquipmentActor}`));

const setEquipmentFullName = setEquipmentOfficer
? `${setEquipmentOfficer.person_guid.last_name}, ${setEquipmentOfficer.person_guid.first_name}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const HWCRFileReview: FC = () => {
const DISPLAY_STATE = 2;
const dispatch = useAppDispatch();
const complaintData = useAppSelector(selectComplaint);
const personGuid = useAppSelector((state) => state.app.profile.personGuid);
const authUserGuid = useAppSelector((state) => state.app.profile.idir);
const isReviewRequired = useAppSelector((state) => state.cases.isReviewRequired);
const reviewCompleteAction = useAppSelector((state) => state.cases.reviewComplete);
const { officers } = useAppSelector((state) => state.officers);
Expand Down Expand Up @@ -49,7 +49,7 @@ export const HWCRFileReview: FC = () => {
if (reviewCompleteAction) {
let displayName = "Unknown";
if (officers) {
const officer = officers.filter((person) => person.person_guid.person_guid === reviewCompleteAction.actor);
const officer = officers.filter((person) => person.auth_user_guid === reviewCompleteAction.actor);
if (officer.length > 0) {
const {
person_guid: { first_name: givenName, last_name: surName },
Expand Down Expand Up @@ -79,7 +79,7 @@ export const HWCRFileReview: FC = () => {
dispatch(createReview(complaintData.id, reviewRequired, null));
} else {
const completeAction = {
actor: personGuid,
actor: authUserGuid,
date: new Date(),
actionCode: "COMPLTREVW",
activeIndicator: reviewCompleted,
Expand All @@ -89,7 +89,7 @@ export const HWCRFileReview: FC = () => {
}
} else {
const completeAction = {
actor: personGuid,
actor: authUserGuid,
date: new Date(),
actionCode: "COMPLTREVW",
activeIndicator: reviewCompleted,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useParams } from "react-router-dom";
import { ComplaintParams } from "../details/complaint-details-edit";
import { createAnimalOutcome, getCaseFile, updateAnimalOutcome } from "../../../../store/reducers/case-thunks";
import { selectAnimalOutcomes, selectCaseId } from "../../../../store/reducers/case-selectors";
import { selectOfficersByAgency } from "../../../../store/reducers/officer";
import { openModal } from "../../../../store/reducers/app";
import { CANCEL_CONFIRM, DELETE_ANIMAL_OUTCOME } from "../../../../types/modal/modal-types";
import { EditOutcome } from "./oucome-by-animal/edit-outcome";
Expand Down Expand Up @@ -51,6 +52,7 @@ export const HWCROutcomeByAnimalv2: FC<props> = () => {
const caseId = useAppSelector(selectCaseId) as UUID;

const { species, ownedBy: agency } = (complaint as WildlifeComplaint) || {};
const officersInAgencyList = useAppSelector(selectOfficersByAgency(agency));

//-- if there's an assigned officer pull them off
//-- the complaint and pass as a kvp to the input
Expand Down Expand Up @@ -139,7 +141,12 @@ export const HWCROutcomeByAnimalv2: FC<props> = () => {
person: { id },
} = assigned;

setAssignedOfficer(id);
if (officersInAgencyList) {
const officerAssigned: any = officersInAgencyList.filter((officer) => officer.person_guid.person_guid === id);
if (officerAssigned.length === 1) {
setAssignedOfficer(officerAssigned[0].auth_user_guid);
}
}
}
}
}, [complaint]);
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, Card } from "react-bootstrap";
import { Officer } from "../../../../types/person/person";
import { useAppDispatch, useAppSelector } from "../../../../hooks/hooks";
import { selectOfficersByAgency } from "../../../../store/reducers/officer";
import { selectOfficerListByAgency, selectOfficersByAgency } from "../../../../store/reducers/officer";
import {
getComplaintById,
selectComplaint,
Expand Down Expand Up @@ -56,13 +56,8 @@ export const HWCRComplaintPrevention: FC = () => {
const { id = "", complaintType = "" } = useParams<ComplaintParams>();
const { ownedByAgencyCode } = useAppSelector(selectComplaintCallerInformation);
const officersInAgencyList = useAppSelector(selectOfficersByAgency(ownedByAgencyCode?.agency));
const assignableOfficers: Option[] =
officersInAgencyList !== null
? officersInAgencyList.map((officer: Officer) => ({
value: officer.person_guid.person_guid,
label: `${officer.person_guid.last_name}, ${officer.person_guid.first_name}`,
}))
: [];
const assignableOfficers = useAppSelector(selectOfficerListByAgency);

const handleDateChange = (date: Date | null) => {
setSelectedDate(date);
};
Expand Down Expand Up @@ -140,7 +135,7 @@ export const HWCRComplaintPrevention: FC = () => {
.map((element: Officer) => {
return {
label: `${element.person_guid?.last_name}, ${element.person_guid?.first_name}`,
value: assigned,
value: element.auth_user_guid,
} as Option;
});
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { from } from "linq-to-typescript";
import { BsExclamationCircleFill } from "react-icons/bs";
import { formatDate, pad } from "../../../../../common/methods";
import { selectOfficersByAgencyDropdown } from "../../../../../store/reducers/officer";
import { selectOfficerListByAgency } from "../../../../../store/reducers/officer";
import { DrugItem } from "./drug-item";
import { Button, Card, Col, ListGroup, Row } from "react-bootstrap";

Expand All @@ -34,7 +34,7 @@ export const AnimalOutcome: FC<props> = ({ index, data, agency, edit, remove })
const threatLevels = useAppSelector(selectThreatLevelDropdown);
const conflictHistories = useAppSelector(selectConflictHistoryDropdown);
const outcomes = useAppSelector(selectWildlifeComplaintOutcome);
const officers = useAppSelector(selectOfficersByAgencyDropdown(agency));
const officers = useAppSelector(selectOfficerListByAgency);
const isInEdit = useAppSelector((state) => state.cases.isInEdit);
const showSectionErrors = !data.outcome && !data.officer && !data.date && isInEdit.showSectionErrors;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { AnimalOutcomeV2 } from "../../../../../types/app/complaints/outcomes/wi
import { AnimalTagV2 } from "../../../../../types/app/complaints/outcomes/wildlife/animal-tag";
import { DrugUsedV2 } from "../../../../../types/app/complaints/outcomes/wildlife/drug-used";
import Option from "../../../../../types/app/option";
import { selectOfficersByAgencyDropdown } from "../../../../../store/reducers/officer";
import { selectOfficerListByAgency } from "../../../../../store/reducers/officer";
import { from } from "linq-to-typescript";
import { EarTag } from "./ear-tag";
import { DrugUsed } from "./drug-used";
Expand Down Expand Up @@ -65,7 +65,7 @@ export const CreateAnimalOutcome: FC<props> = ({ index, assignedOfficer: officer
const threatLevels = useAppSelector(selectThreatLevelDropdown);
const conflictHistories = useAppSelector(selectConflictHistoryDropdown);
const outcomes = useAppSelector(selectWildlifeComplaintOutcome);
const officers = useAppSelector(selectOfficersByAgencyDropdown(agency));
const officers = useAppSelector(selectOfficerListByAgency);
const isInEdit = useAppSelector((state) => state.cases.isInEdit);
const showSectionErrors = isInEdit.showSectionErrors;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { forwardRef, useImperativeHandle, useState } from "react";
import { DrugAuthorizationV2 } from "../../../../../types/app/complaints/outcomes/wildlife/drug-authorization";
import { CompSelect } from "../../../../common/comp-select";
import { useAppSelector } from "../../../../../hooks/hooks";
import { selectOfficersByAgencyDropdown } from "../../../../../store/reducers/officer";
import { selectOfficerListByAgency } from "../../../../../store/reducers/officer";
import { ValidationDatePicker } from "../../../../../common/validation-date-picker";
import Option from "../../../../../types/app/option";
import { REQUIRED } from "../../../../../constants/general";
Expand All @@ -24,7 +24,7 @@ export const DrugAuthorizedBy = forwardRef<refProps, props>((props, ref) => {
drugAuthorization: { officer, date },
} = props;

const officers = useAppSelector(selectOfficersByAgencyDropdown(agency));
const officers = useAppSelector(selectOfficerListByAgency);

//-- errors
const [officerError, setOfficerError] = useState("");
Expand Down
Loading

0 comments on commit 5e692c6

Please sign in to comment.