diff --git a/backend/db/migrations/V0.16.0__CE-603.sql b/backend/db/migrations/V0.16.0__CE-603.sql deleted file mode 100644 index e69de29bb..000000000 diff --git a/frontend/src/app/components/containers/complaints/outcomes/animal-outcomes/drug-authorization.tsx b/frontend/src/app/components/containers/complaints/outcomes/animal-outcomes/drug-authorization.tsx index 6fdeb3c7e..fc4fc5721 100644 --- a/frontend/src/app/components/containers/complaints/outcomes/animal-outcomes/drug-authorization.tsx +++ b/frontend/src/app/components/containers/complaints/outcomes/animal-outcomes/drug-authorization.tsx @@ -38,17 +38,9 @@ export const DrugAuthorization: FC = ({ agency, drugAuthorization, update update(newDrugAuth, "officer"); }; - const handleAuthorizedOnChange = (input: Date | undefined) => { - setAuthorizedOn(input ?? undefined); - update( - { - officer: authorizedBy, - date: input ?? undefined, - officerErrorMessage: drugAuthorization?.officerErrorMessage, - dateErrorMessage: drugAuthorization?.dateErrorMessage, - }, - "date", - ); + const handleAuthorizedOnChange = (input: Date) => { + setAuthorizedOn(input); + update({ officer: authorizedBy, officerErrorMessage: drugAuthorization?.officerErrorMessage, date: input }, "date"); }; return ( diff --git a/frontend/src/app/components/containers/complaints/outcomes/animal-outcomes/edit-animal-outcome.tsx b/frontend/src/app/components/containers/complaints/outcomes/animal-outcomes/edit-animal-outcome.tsx index 0310c3ca6..e1353472b 100644 --- a/frontend/src/app/components/containers/complaints/outcomes/animal-outcomes/edit-animal-outcome.tsx +++ b/frontend/src/app/components/containers/complaints/outcomes/animal-outcomes/edit-animal-outcome.tsx @@ -1,4 +1,4 @@ -import { FC, useState } from "react"; +import { FC, useState, useEffect } from "react"; import { ToastContainer } from "react-toastify"; import { v4 as uuidv4 } from "uuid"; @@ -82,6 +82,18 @@ export const EditAnimalOutcome: FC = ({ const [outcomeOfficerErrorMessage, setOutcomeOfficerErrorMessage] = useState(""); const [outcomeDateErrorMessage, setOutcomeDateErrorMessage] = useState(""); + useEffect(() => { + const date = animalOutcomeItemData?.date ? new Date(animalOutcomeItemData?.date) : new Date(); + const defaultDateDrug = animalOutcomeItemData?.drugAuthorization?.date + ? new Date(animalOutcomeItemData?.drugAuthorization?.date) + : new Date(); + setOutcomeDate(date); + setDrugAuthorization({ + officer: animalOutcomeItemData?.officer?.value ?? "", + date: defaultDateDrug, + }); + }, [animalOutcomeItemData]); + const handleSaveAnimalOutcome = () => { const id = editMode ? animalOutcomeItemData?.id?.toString() : uuidv4(); const newAnimalOutcome: AnimalOutcome = { diff --git a/frontend/src/app/store/reducers/case-thunks.ts b/frontend/src/app/store/reducers/case-thunks.ts index dc6851bb8..ac180dd2c 100644 --- a/frontend/src/app/store/reducers/case-thunks.ts +++ b/frontend/src/app/store/reducers/case-thunks.ts @@ -88,6 +88,7 @@ const addAssessment = codeTables: { "assessment-type": assessmentType }, officers: { officers }, app: { profile }, + cases: { caseId }, } = getState(); let createAssessmentInput = { createAssessmentInput: { @@ -137,6 +138,7 @@ const addAssessment = const updatedAssessmentData = await parseAssessmentResponse(res, officers); if (res) { dispatch(setAssessment({ assessment: updatedAssessmentData })); + if (!caseId) dispatch(setCaseId(res.caseIdentifier)); ToggleSuccess(`Assessment has been saved`); } else { await dispatch(clearAssessment()); @@ -290,6 +292,7 @@ const addPrevention = codeTables: { "prevention-type": preventionType }, officers: { officers }, app: { profile }, + cases: { caseId }, } = getState(); let createPreventionInput = { createPreventionInput: { @@ -338,6 +341,7 @@ const addPrevention = const updatedPreventionData = await parsePreventionResponse(res, officers); if (res) { dispatch(setPrevention({ prevention: updatedPreventionData })); + if (!caseId) dispatch(setCaseId(res.caseIdentifier)); ToggleSuccess(`Prevention and education has been saved`); } else { await dispatch(clearPrevention()); @@ -510,7 +514,8 @@ export const upsertNote = result = await dispatch(_createNote(id, note, officer ? officer.officer_guid : "", idir)); if (result !== null) { - dispatch(setCaseId(result.caseIdentifier)); + dispatch(setCaseId(result.caseIdentifier)); //ideally check if caseId exists first, if not then do this function. + ToggleSuccess("Supplemental note created"); } else { ToggleError("Error, unable to create supplemental note"); @@ -612,9 +617,7 @@ export const createReview = const parameters = generateApiParameters(`${config.API_BASE_URL}/v1/case/review`, reviewInput); await post(dispatch, parameters).then(async (res) => { if (res) { - if (!caseId) { - dispatch(setCaseId(res.caseIdentifier)); - } + if (!caseId) dispatch(setCaseId(res.caseIdentifier)); dispatch(setIsReviewedRequired(res.isReviewRequired)); if (res.reviewComplete) { dispatch(setReviewComplete(res.reviewComplete)); @@ -669,6 +672,7 @@ export const deleteEquipment = id: id, updateUserId: profile.idir_username, }; + const parameters = generateApiParameters(`${config.API_BASE_URL}/v1/case/equipment`, deleteEquipmentInput); await deleteMethod(dispatch, parameters).then(async (res) => { if (res) { @@ -695,6 +699,7 @@ export const upsertEquipment = const { app: { profile }, + cases: { caseId }, } = getState(); // equipment does not exist, let's create it if (complaintIdentifier && !equipment.id) { @@ -711,6 +716,7 @@ export const upsertEquipment = await post(dispatch, parameters).then(async (res) => { if (res) { dispatch(setCaseFile(res)); + if (!caseId) dispatch(setCaseId(res.caseIdentifier)); ToggleSuccess(`Equipment has been updated`); } else { ToggleError(`Unable to update equipment`);