From 88e5e656ce33cf3ca858770dd50f16f4b28e0c1f Mon Sep 17 00:00:00 2001 From: eirikhaugstulen Date: Wed, 3 Apr 2024 15:58:41 +0200 Subject: [PATCH] fix: revert uid on failed save --- .../RegistrationDataEntry/RegistrationDataEntry.epics.js | 9 +++++++++ src/epics/trackerCapture.epics.js | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core_modules/capture-core/components/Pages/New/RegistrationDataEntry/RegistrationDataEntry.epics.js b/src/core_modules/capture-core/components/Pages/New/RegistrationDataEntry/RegistrationDataEntry.epics.js index 686fa6b24e..d14df1119e 100644 --- a/src/core_modules/capture-core/components/Pages/New/RegistrationDataEntry/RegistrationDataEntry.epics.js +++ b/src/core_modules/capture-core/components/Pages/New/RegistrationDataEntry/RegistrationDataEntry.epics.js @@ -17,6 +17,7 @@ import { getStageWithOpenAfterEnrollment, PAGES, } from './helpers'; +import { cleanUpUid } from '../NewPage.actions'; export const startSavingNewTrackedEntityInstanceEpic: Epic = (action$: InputObservable) => action$.pipe( @@ -140,3 +141,11 @@ export const completeSavingNewTrackedEntityInstanceWithEnrollmentEpic = ( })); }), ); + +export const failedSavingNewTrackedEntityInstanceWithEnrollmentEpic = ( + action$: InputObservable, +) => + action$.pipe( + ofType(registrationFormActionTypes.NEW_TRACKED_ENTITY_INSTANCE_WITH_ENROLLMENT_SAVE_FAILED), + map(() => cleanUpUid()), + ); diff --git a/src/epics/trackerCapture.epics.js b/src/epics/trackerCapture.epics.js index d0206db8b9..a3c50c5477 100644 --- a/src/epics/trackerCapture.epics.js +++ b/src/epics/trackerCapture.epics.js @@ -182,7 +182,7 @@ import { } from '../core_modules/capture-core/components/DataEntries/TeiRegistrationEntry/TeiRegistrationEntry.epics'; import { completeSavingNewTrackedEntityInstanceEpic, - completeSavingNewTrackedEntityInstanceWithEnrollmentEpic, + completeSavingNewTrackedEntityInstanceWithEnrollmentEpic, failedSavingNewTrackedEntityInstanceWithEnrollmentEpic, startSavingNewTrackedEntityInstanceEpic, startSavingNewTrackedEntityInstanceWithEnrollmentEpic, } from '../core_modules/capture-core/components/Pages/New/RegistrationDataEntry/RegistrationDataEntry.epics'; @@ -341,6 +341,7 @@ export const epics = combineEpics( startSavingNewTrackedEntityInstanceWithEnrollmentEpic, completeSavingNewTrackedEntityInstanceEpic, completeSavingNewTrackedEntityInstanceWithEnrollmentEpic, + failedSavingNewTrackedEntityInstanceWithEnrollmentEpic, changedEnrollmentIdEpic, fetchEnrollmentIdEpic, verifyEnrollmentIdSuccessEpic,