From a87ba794b6ce0fcbeeb105b75c5e1ecc127a21f6 Mon Sep 17 00:00:00 2001 From: "Md. Ashikul Alam" <32668488+Nil20@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:30:19 +0600 Subject: [PATCH] (Configurable roles) Unassign scope fix (#8305) * fix: update unassign conditional query * fix: update wq record assignment value while assign and unassign based on hearth bundle * Revert "fix: update wq record assignment value while assign and unassign based on hearth bundle" This reverts commit b6a4aa75cc3c61f94419f623c42a0b7cc68fc479. * fix: add assignment property in declaration --- packages/client/src/declarations/index.ts | 6 ++++++ .../src/views/DataProvider/birth/queries.ts | 7 +++++++ .../src/views/DataProvider/death/queries.ts | 7 +++++++ .../src/views/DataProvider/marriage/queries.ts | 7 +++++++ .../src/views/RecordAudit/RecordAudit.tsx | 2 +- .../features/registration/root-resolvers.ts | 18 +++++++++--------- 6 files changed, 37 insertions(+), 10 deletions(-) diff --git a/packages/client/src/declarations/index.ts b/packages/client/src/declarations/index.ts index 42f57b1bec..9316ee934b 100644 --- a/packages/client/src/declarations/index.ts +++ b/packages/client/src/declarations/index.ts @@ -21,6 +21,7 @@ import { } from '@client/forms' import { SCOPES } from '@opencrvs/commons/client' import { + AssignmentData, Attachment, EventType, History, @@ -230,6 +231,7 @@ export interface IDeclaration { writingDraft?: boolean operationHistories?: ITaskHistory[] isNotDuplicate?: boolean + assignmentStatus?: AssignmentData } type Relation = @@ -1531,6 +1533,10 @@ export const declarationsReducer: LoopReducer = ( newDeclarationsAfterDownload[downloadingDeclarationIndex].downloadStatus = DOWNLOAD_STATUS.DOWNLOADED + newDeclarationsAfterDownload[ + downloadingDeclarationIndex + ].assignmentStatus = eventData?.registration?.assignment ?? null + const newStateAfterDownload = { ...state, declarations: newDeclarationsAfterDownload diff --git a/packages/client/src/views/DataProvider/birth/queries.ts b/packages/client/src/views/DataProvider/birth/queries.ts index e46a961a33..a874176802 100644 --- a/packages/client/src/views/DataProvider/birth/queries.ts +++ b/packages/client/src/views/DataProvider/birth/queries.ts @@ -149,6 +149,13 @@ const GET_BIRTH_REGISTRATION_FOR_REVIEW = gql` contactRelationship contactPhoneNumber contactEmail + assignment { + practitionerId + firstName + lastName + officeName + avatarURL + } certificates { hasShowedVerifiedDocument certificateTemplateId diff --git a/packages/client/src/views/DataProvider/death/queries.ts b/packages/client/src/views/DataProvider/death/queries.ts index 1cee40f734..2339546da2 100644 --- a/packages/client/src/views/DataProvider/death/queries.ts +++ b/packages/client/src/views/DataProvider/death/queries.ts @@ -535,6 +535,13 @@ export const GET_DEATH_REGISTRATION_FOR_CERTIFICATION = gql` contactEmail contactPhoneNumber informantsSignature + assignment { + practitionerId + firstName + lastName + officeName + avatarURL + } duplicates { compositionId trackingId diff --git a/packages/client/src/views/DataProvider/marriage/queries.ts b/packages/client/src/views/DataProvider/marriage/queries.ts index 4b94352055..456a1f65da 100644 --- a/packages/client/src/views/DataProvider/marriage/queries.ts +++ b/packages/client/src/views/DataProvider/marriage/queries.ts @@ -502,6 +502,13 @@ const GET_MARRIAGE_REGISTRATION_FOR_CERTIFICATE = gql` brideSignature witnessOneSignature witnessTwoSignature + assignment { + practitionerId + firstName + lastName + officeName + avatarURL + } duplicates { compositionId trackingId diff --git a/packages/client/src/views/RecordAudit/RecordAudit.tsx b/packages/client/src/views/RecordAudit/RecordAudit.tsx index b7e85a7c4c..f2a5abbd55 100644 --- a/packages/client/src/views/RecordAudit/RecordAudit.tsx +++ b/packages/client/src/views/RecordAudit/RecordAudit.tsx @@ -576,7 +576,7 @@ const BodyContent = ({ draft.submissionStatus === SUBMISSION_STATUS.DRAFT) ? { ...getDraftDeclarationData(draft, resources, intl, trackingId), - assignment: workqueueDeclaration?.registration?.assignment + assignment: draft?.assignmentStatus } : getWQDeclarationData( workqueueDeclaration as NonNullable, diff --git a/packages/gateway/src/features/registration/root-resolvers.ts b/packages/gateway/src/features/registration/root-resolvers.ts index 7d721cd2a3..0d1bf03e50 100644 --- a/packages/gateway/src/features/registration/root-resolvers.ts +++ b/packages/gateway/src/features/registration/root-resolvers.ts @@ -582,17 +582,17 @@ export const resolvers: GQLResolver = { async markEventAsUnassigned(_, { id }, { headers: authHeader }) { const assignedToSelf = await checkUserAssignment(id, authHeader) if ( - !assignedToSelf || - !inScope(authHeader, [SCOPES.RECORD_UNASSIGN_OTHERS]) + assignedToSelf || + inScope(authHeader, [SCOPES.RECORD_UNASSIGN_OTHERS]) ) { - throw new Error('User does not have enough scope') - } - const task = getTaskFromSavedBundle( - await unassignRegistration(id, authHeader) - ) + const task = getTaskFromSavedBundle( + await unassignRegistration(id, authHeader) + ) - // return the taskId - return task.id + // return the taskId + return task.id + } + throw new Error('User does not have enough scope') }, async markEventAsDuplicate( _,