Skip to content

Commit

Permalink
update note functionality
Browse files Browse the repository at this point in the history
added functionality to update supplemental note
  • Loading branch information
Mike Sears committed Mar 25, 2024
1 parent 3b22b8c commit 65f8685
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
8 changes: 8 additions & 0 deletions backend/src/case_file/case_file.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ input CreateSupplementalNoteInput {
createUserId: String!
}

input UpdateSupplementalNoteInput {
caseIdentifier: String!
note: String!
actor: String!
updateUserId: String!
}

type Query {
getCaseFile( caseIdentifier: String!): CaseFile
getCaseFileByLeadId( leadIdentifier: String!): CaseFile
Expand All @@ -130,4 +137,5 @@ type Mutation {
updatePrevention(updatePreventionInput: UpdatePreventionInput!): CaseFile!

createNote(input: CreateSupplementalNoteInput!): CaseFile!
updateNote(input: UpdateSupplementalNoteInput!): CaseFile!
}
7 changes: 7 additions & 0 deletions backend/src/case_file/case_file.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { UseGuards } from "@nestjs/common";
import { Role } from "../enum/role.enum";
import { Roles } from "../auth/decorators/roles.decorator";
import { CreateSupplementalNoteInput } from './dto/supplemental-note/create-supplemental-note.input';
import { UpdateSupplementalNoteInput } from './dto/supplemental-note/update-supplemental-note.input';

@UseGuards(JwtRoleGuard)
@Resolver('CaseFile')
Expand Down Expand Up @@ -54,4 +55,10 @@ export class CaseFileResolver {
createNote(@Args("input") input: CreateSupplementalNoteInput) {
return this.caseFileService.createNote(input);
}

@Mutation("updateNote")
@Roles(Role.COS_OFFICER)
updateNote(@Args("input") input: UpdateSupplementalNoteInput) {
return this.caseFileService.updateNote(input);
}
}
7 changes: 7 additions & 0 deletions backend/src/case_file/case_file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { GraphQLError } from "graphql";
import { CreateSupplementalNoteInput } from "./dto/supplemental-note/create-supplemental-note.input";
import { Note } from "./entities/supplemental-note/supplemental-note.entity";
import { ACTION_CODES } from "../common/action_codes";
import { UpdateSupplementalNoteInput } from "./dto/supplemental-note/update-supplemental-note.input";

@Injectable()
export class CaseFileService {
Expand Down Expand Up @@ -633,6 +634,12 @@ export class CaseFileService {
return await this._upsertNote(caseFileId, note, actor, createUserId);
};

updateNote = async (input: UpdateSupplementalNoteInput): Promise<CaseFile> => {
const { caseIdentifier: caseFileId, actor, note, updateUserId } = input;

return await this._upsertNote(caseFileId, note, actor, updateUserId);
}

private _upsertNote = async (caseId: string, note: string, actor: string, userId: string): Promise<CaseFile> => {
const _hasAction = async (caseId: string): Promise<boolean> => {
const NOTES_QUERY = `SELECT a.action_type_action_xref_guid AS actionId FROM case_management.action_type_action_xref atax
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export class CreateSupplementalNoteInput {
createUserId: string;
actor: string;
note: string;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class UpdateSupplementalNoteInput {
caseIdentifier: string;
updateUserId: string;
actor: string;
note: string;
}

0 comments on commit 65f8685

Please sign in to comment.