From 08fa1692cb1ef1a585d6639ed20b08352a83a00f Mon Sep 17 00:00:00 2001 From: henrikmv Date: Mon, 25 Nov 2024 17:06:24 +0100 Subject: [PATCH] feat: add selected org unit to payload --- .../DataEntry/DataEntry.component.js | 2 +- .../DataEntry/helpers/getOpenDataEntryActions.js | 2 +- .../Validated/getConvertedAddEvent.js | 8 ++------ .../Validated/useBuildNewEventPayload.js | 4 ---- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/DataEntry.component.js b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/DataEntry.component.js index 38689f9c84..f07359bc2b 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/DataEntry.component.js +++ b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/DataEntry.component.js @@ -192,7 +192,7 @@ const buildOrgUnitSettingsFn = () => { label: i18n.t('Organisation unit'), required: true, }), - getPropName: () => 'orgUnitId', + getPropName: () => 'orgUnit', getValidatorContainers: () => getOrgUnitValidatorContainers(), getMeta: () => ({ placement: placements.TOP, diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/helpers/getOpenDataEntryActions.js b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/helpers/getOpenDataEntryActions.js index 330aecbabf..c5481bf76c 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/helpers/getOpenDataEntryActions.js +++ b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/helpers/getOpenDataEntryActions.js @@ -16,7 +16,7 @@ const dataEntryPropsToInclude: DataEntryPropsToInclude = [ validatorContainers: getEventDateValidatorContainers(), }, { - id: 'orgUnitId', + id: 'orgUnit', type: 'ORGANISATION_UNIT', validatorContainers: getOrgUnitValidatorContainers(), }, diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/getConvertedAddEvent.js b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/getConvertedAddEvent.js index bbfb66046c..8cc308c31e 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/getConvertedAddEvent.js +++ b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/getConvertedAddEvent.js @@ -11,8 +11,6 @@ export const getAddEventEnrollmentServerData = ({ mainDataClientValues, eventId, programId, - orgUnitId, - orgUnitName, teiId, enrollmentId, completed, @@ -25,8 +23,6 @@ export const getAddEventEnrollmentServerData = ({ mainDataClientValues: Object, eventId: string, programId: string, - orgUnitId: string, - orgUnitName: string, teiId: string, enrollmentId: string, completed?: boolean, @@ -49,11 +45,11 @@ export const getAddEventEnrollmentServerData = ({ event: eventId, program: programId, programStage: formFoundation.id, - orgUnit: orgUnitId, + orgUnit: mainDataServerValues.orgUnit.id, + orgUnitName: mainDataServerValues.orgUnit.name, trackedEntity: teiId, enrollment: enrollmentId, scheduledAt: mainDataServerValues.occurredAt, - orgUnitName, updatedAt, uid, dataValues: Object diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/useBuildNewEventPayload.js b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/useBuildNewEventPayload.js index e4269a87e1..ac81170a09 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/useBuildNewEventPayload.js +++ b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/useBuildNewEventPayload.js @@ -51,11 +51,9 @@ export const createServerData = ({ export const useBuildNewEventPayload = ({ dataEntryId, itemId, - orgUnitId, programId, teiId, enrollmentId, - orgUnitName, formFoundation, }: Props) => { const { serverVersion: { minor } } = useConfig(); @@ -139,10 +137,8 @@ export const useBuildNewEventPayload = ({ eventId: requestEventId, mainDataClientValues: { ...dataEntryClientValues, notes: notesValues }, programId, - orgUnitId, enrollmentId, teiId, - orgUnitName, completed: saveType === addEventSaveTypes.COMPLETE, fromClientDate, serverMinorVersion: minor,