Skip to content

Commit

Permalink
chore(case management)!: CE-579 Refactor (#418)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike <[email protected]>
  • Loading branch information
barrfalk and marqueone-ps authored May 14, 2024
1 parent faebdd8 commit aba8b1f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
22 changes: 14 additions & 8 deletions backend/src/v1/case_file/case_file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class CaseFileService {
actionJustificationLongDescription
actionJustificationActiveIndicator
actions {
actionGuid
actionId
actor
date
actionCode
Expand All @@ -43,7 +43,7 @@ export class CaseFileService {
}
preventionDetails {
actions {
actionGuid
actionId
actor
date
actionCode
Expand All @@ -58,7 +58,8 @@ export class CaseFileService {
actor
actionCode
date,
actionGuid
actionId,
activeIndicator
}
}
equipment {
Expand All @@ -70,7 +71,7 @@ export class CaseFileService {
yCoordinate
createDate
actions {
actionGuid
actionId
actor
actionCode
date
Expand All @@ -84,12 +85,17 @@ export class CaseFileService {
}

find = async (complaint_id: string, token: string): Promise<CaseFileDto> => {
const { data } = await get(token, {
const { data, errors } = await get(token, {
query: `{getCaseFileByLeadId (leadIdentifier: "${complaint_id}")
${this.caseFileQueryFields}
}`,
});

if (errors) {
this.logger.error("GraphQL errors:", errors);
throw new Error("GraphQL errors occurred");
}

if (data?.getCaseFileByLeadId?.caseIdentifier) {
const caseFileDto = data.getCaseFileByLeadId as CaseFileDto;
return caseFileDto;
Expand Down Expand Up @@ -233,7 +239,7 @@ export class CaseFileService {
query: `mutation CreateNote($input: CreateSupplementalNoteInput!) {
createNote(input: $input) {
caseIdentifier
note { note, action { actor,date,actionCode, actionGuid } }
note { note, action { actor,date,actionCode, actionId } }
}
}`,
variables: { input: model },
Expand All @@ -248,7 +254,7 @@ export class CaseFileService {
query: `mutation UpdateNote($input: UpdateSupplementalNoteInput!) {
updateNote(input: $input) {
caseIdentifier
note { note, action { actor,date,actionCode,actionGuid } }
note { note, action { actor,date,actionCode, actionId } }
}
}`,
variables: { input: model },
Expand All @@ -263,7 +269,7 @@ export class CaseFileService {
query: `mutation DeleteNote($input: DeleteSupplementalNoteInput!) {
deleteNote(input: $input) {
caseIdentifier
note { note, action { actor,date,actionCode,actionGuid } }
note { note, action { actor,date,actionCode, actionId } }
}
}`,
variables: { input: model },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ export const HWCRSupplementalNotes: FC = () => {

const renderNote = useMemo(() => {
const { action, note } = !supplementalNote ? { action: undefined, note: "" } : supplementalNote;

if (action && !showInput) {
if (action?.activeIndicator && !showInput) {
return (
<SupplementalNotesItem
notes={note}
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/app/store/reducers/case-thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,9 @@ export const upsertNote =
}
} else {
const {
action: { actionGuid },
action: { actionId },
} = currentNote;
result = await dispatch(_updateNote(id as UUID, note, officer ? officer.officer_guid : "", idir, actionGuid));
result = await dispatch(_updateNote(id as UUID, note, officer ? officer.officer_guid : "", idir, actionId));

if (result !== null) {
dispatch(setCaseId(result.caseIdentifier));
Expand Down Expand Up @@ -572,11 +572,11 @@ export const deleteNote =

if (currentNote?.action) {
const {
action: { actionGuid },
action: { actionId },
} = currentNote;

const officer = officers.find((item) => item.user_id === idir);
const result = await dispatch(_deleteNote(caseId as UUID, officer ? officer.officer_guid : "", idir, actionGuid));
const result = await dispatch(_deleteNote(caseId as UUID, officer ? officer.officer_guid : "", idir, actionId));

if (result !== null) {
ToggleSuccess("Supplemental note deleted");
Expand Down Expand Up @@ -672,7 +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 Down
3 changes: 2 additions & 1 deletion frontend/src/app/types/outcomes/case-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export interface CaseAction {
actor: string;
date: Date;
action: string;
actionGuid: string;
actionId: string;
activeIndicator: boolean;
}

0 comments on commit aba8b1f

Please sign in to comment.