Skip to content

Commit

Permalink
fix: CE-608-v2 and CE-600 (#370)
Browse files Browse the repository at this point in the history
Co-authored-by: afwilcox <[email protected]>
Co-authored-by: Mike <[email protected]>
Co-authored-by: Barrett Falk <[email protected]>
  • Loading branch information
4 people authored Apr 26, 2024
1 parent d17148e commit 91a7f59
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,9 @@ export const DrugAuthorization: FC<Props> = ({ 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 (
Expand Down
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -82,6 +82,18 @@ export const EditAnimalOutcome: FC<EditAnimalOutcomeProps> = ({
const [outcomeOfficerErrorMessage, setOutcomeOfficerErrorMessage] = useState<string>("");
const [outcomeDateErrorMessage, setOutcomeDateErrorMessage] = useState<string>("");

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 = {
Expand Down
14 changes: 10 additions & 4 deletions frontend/src/app/store/reducers/case-thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const addAssessment =
codeTables: { "assessment-type": assessmentType },
officers: { officers },
app: { profile },
cases: { caseId },
} = getState();
let createAssessmentInput = {
createAssessmentInput: {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -290,6 +292,7 @@ const addPrevention =
codeTables: { "prevention-type": preventionType },
officers: { officers },
app: { profile },
cases: { caseId },
} = getState();
let createPreventionInput = {
createPreventionInput: {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -612,9 +617,7 @@ export const createReview =
const parameters = generateApiParameters(`${config.API_BASE_URL}/v1/case/review`, reviewInput);
await post<CaseFileDto>(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));
Expand Down Expand Up @@ -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<boolean>(dispatch, parameters).then(async (res) => {
if (res) {
Expand All @@ -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) {
Expand All @@ -711,6 +716,7 @@ export const upsertEquipment =
await post<CaseFileDto>(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`);
Expand Down

0 comments on commit 91a7f59

Please sign in to comment.