Skip to content

Commit

Permalink
fix: update redux migration for File Review (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scarlett-Truong authored Apr 8, 2024
1 parent 50f9c13 commit 6bf5e7e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
5 changes: 3 additions & 2 deletions backend/src/v1/case_file/case_file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,15 @@ export class CaseFileService {
const result = await post(token, {
query: `mutation CreateNote($input: CreateSupplementalNoteInput!) {
createNote(input: $input) {
caseIdentifier
note { note, action { actor,date,actionCode } }
}
}`,
variables: { input: model },
});
const returnValue = await this.handleAPIResponse(result);

return returnValue?.createNotes;
return returnValue?.createNote;
};

updateNote = async (token: any, model: UpdateSupplementalNotesInput): Promise<CaseFileDto> => {
Expand All @@ -223,6 +224,6 @@ export class CaseFileService {
});
const returnValue = await this.handleAPIResponse(result);

return returnValue?.updateNotes;
return returnValue?.updateNote;
};
}
11 changes: 10 additions & 1 deletion frontend/src/app/store/migrations.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Migration1 } from "./migrations/migration-1";
import { Migration2 } from "./migrations/migration-2";
import { Migration3 } from "./migrations/migration-3";
import { AddOutcomeNote } from "./migrations/migration-4";
import { AddPersonGuidAndOutcomeReview } from "./migrations/migration-5";

const BaseMigration = {
0: (state: any) => {
Expand All @@ -11,6 +13,13 @@ const BaseMigration = {
};

let migration = {...BaseMigration}
migration = {...migration, ...Migration1, ...Migration2, ...Migration3};
migration = {
...migration,
...Migration1,
...Migration2,
...Migration3,
...AddOutcomeNote,
...AddPersonGuidAndOutcomeReview
};

export default migration;
17 changes: 17 additions & 0 deletions frontend/src/app/store/migrations/migration-5.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//Add personGuid in app and isReviewRequired,reviewComplete in cases
export const AddPersonGuidAndOutcomeReview = {
5: (state: any) => {
return {
...state,
app: {
profile: {
personGuid: ""
},
},
cases: {
isReviewRequired: false,
reviewComplete: null
},
};
},
};
3 changes: 3 additions & 0 deletions frontend/src/app/store/reducers/cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ const addPrevention =
const updatedPreventionData = await parsePreventionResponse(res, officers);
if (res) {
dispatch(setPrevention({ prevention: updatedPreventionData }));
dispatch(setCaseId(res.caseIdentifier));
ToggleSuccess(`Prevention and education has been saved`);
} else {
await dispatch(clearPrevention());
Expand Down Expand Up @@ -422,6 +423,7 @@ const addAssessment =
const updatedAssessmentData = await parseAssessmentResponse(res, officers);
if (res) {
dispatch(setAssessment({ assessment: updatedAssessmentData }));
dispatch(setCaseId(res.caseIdentifier));
ToggleSuccess(`Assessment has been saved`);
} else {
await dispatch(clearAssessment());
Expand Down Expand Up @@ -644,6 +646,7 @@ export const upsertNote =
if (!currentNote?.action) {
result = await dispatch(_createNote(id, note, officer ? officer.officer_guid : "", idir));
if (result !== null) {
dispatch(setCaseId(result.caseIdentifier));
ToggleSuccess("Supplemental note created");
} else {
ToggleError("Error, unable to create supplemental note");
Expand Down

0 comments on commit 6bf5e7e

Please sign in to comment.