Skip to content

Commit

Permalink
fix: find office location from current task (#7765)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zangetsu101 authored Oct 17, 2024
1 parent 6fd0d75 commit be66d58
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions packages/gateway/src/features/registration/type-resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ import {
findLastOfficeLocationFromSavedBundle,
notCorrectedHistory,
findResourceFromBundleById,
getUserRoleFromHistory
getUserRoleFromHistory,
SavedOffice
} from '@opencrvs/commons/types'

import { GQLQuestionnaireQuestion, GQLResolver } from '@gateway/graphql/schema'
Expand Down Expand Up @@ -1520,7 +1521,7 @@ export const typeResolvers: GQLResolver = {

return userResponse
},
system: async (task: Task, _: any, { headers: authHeader }) => {
system: async (task: Task, _: any) => {
const systemIdentifier = task.identifier?.find(
({ system }) =>
system === `${OPENCRVS_SPECIFICATION_URL}id/system_identifier`
Expand All @@ -1530,15 +1531,26 @@ export const typeResolvers: GQLResolver = {
}
return JSON.parse(systemIdentifier.value)
},
location: async (task: Task, _: any, { dataSources, record }) => {
const taskLocation = findExtension(
location: async (task: Task, _: any, { record }) => {
const officeExtension = findExtension(
`${OPENCRVS_SPECIFICATION_URL}extension/regLastOffice`,
task.extension as Extension[]
task.extension
)
if (!taskLocation || !record) {
if (!officeExtension || !record) {
return null
}
return findLastOfficeLocationFromSavedBundle(record)
const office = findResourceFromBundleById<SavedOffice>(
record,
resourceIdentifierToUUID(officeExtension.valueReference.reference)
)
if (!office || !office.partOf) {
return null
}
const officeLocation = findResourceFromBundleById<SavedLocation>(
record,
resourceIdentifierToUUID(office.partOf.reference)
)
return officeLocation
},
office: async (task: Task, _: any, { dataSources }) => {
const taskLocation = findExtension(
Expand Down

0 comments on commit be66d58

Please sign in to comment.