Skip to content

Commit

Permalink
(Configurable roles) Unassign scope fix (#8305)
Browse files Browse the repository at this point in the history
* 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 b6a4aa7.

* fix: add assignment property in declaration
  • Loading branch information
Nil20 authored Jan 10, 2025
1 parent 5ae2637 commit a87ba79
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 10 deletions.
6 changes: 6 additions & 0 deletions packages/client/src/declarations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from '@client/forms'
import { SCOPES } from '@opencrvs/commons/client'
import {
AssignmentData,
Attachment,
EventType,
History,
Expand Down Expand Up @@ -230,6 +231,7 @@ export interface IDeclaration {
writingDraft?: boolean
operationHistories?: ITaskHistory[]
isNotDuplicate?: boolean
assignmentStatus?: AssignmentData
}

type Relation =
Expand Down Expand Up @@ -1531,6 +1533,10 @@ export const declarationsReducer: LoopReducer<IDeclarationsState, Action> = (
newDeclarationsAfterDownload[downloadingDeclarationIndex].downloadStatus =
DOWNLOAD_STATUS.DOWNLOADED

newDeclarationsAfterDownload[
downloadingDeclarationIndex
].assignmentStatus = eventData?.registration?.assignment ?? null

const newStateAfterDownload = {
...state,
declarations: newDeclarationsAfterDownload
Expand Down
7 changes: 7 additions & 0 deletions packages/client/src/views/DataProvider/birth/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ const GET_BIRTH_REGISTRATION_FOR_REVIEW = gql`
contactRelationship
contactPhoneNumber
contactEmail
assignment {
practitionerId
firstName
lastName
officeName
avatarURL
}
certificates {
hasShowedVerifiedDocument
certificateTemplateId
Expand Down
7 changes: 7 additions & 0 deletions packages/client/src/views/DataProvider/death/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,13 @@ export const GET_DEATH_REGISTRATION_FOR_CERTIFICATION = gql`
contactEmail
contactPhoneNumber
informantsSignature
assignment {
practitionerId
firstName
lastName
officeName
avatarURL
}
duplicates {
compositionId
trackingId
Expand Down
7 changes: 7 additions & 0 deletions packages/client/src/views/DataProvider/marriage/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,13 @@ const GET_MARRIAGE_REGISTRATION_FOR_CERTIFICATE = gql`
brideSignature
witnessOneSignature
witnessTwoSignature
assignment {
practitionerId
firstName
lastName
officeName
avatarURL
}
duplicates {
compositionId
trackingId
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/views/RecordAudit/RecordAudit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof workqueueDeclaration>,
Expand Down
18 changes: 9 additions & 9 deletions packages/gateway/src/features/registration/root-resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
_,
Expand Down

0 comments on commit a87ba79

Please sign in to comment.