Skip to content

Commit

Permalink
fix: [DHIS2-18355] runtime error occurs when saving empty widget in R…
Browse files Browse the repository at this point in the history
…elated stages (#3935)

fix: runtime error occurs when saving empty widget in Related stages
  • Loading branch information
alaa-yahia authored Jan 13, 2025
1 parent 33093e0 commit 4ebef85
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const Validated = ({
formFoundationArgument: RenderFoundation,
saveType: ?$Values<typeof addEventSaveTypes>,
enrollment: ?Object,
) => new Promise((resolve, reject) => {
) => new Promise((resolve) => {
// Creating a promise to be able to stop navigation if related stages has an error
window.scrollTo(0, 0);
const {
Expand All @@ -94,7 +94,7 @@ export const Validated = ({
);

if (formHasError) {
reject(new Error('Form has error'));
resolve({ success: false });
return;
}

Expand Down Expand Up @@ -127,13 +127,12 @@ export const Validated = ({
], newEventBatchActionTypes.REQUEST_SAVE_AND_SET_SUBMISSION_IN_PROGRESS),
);

resolve();
resolve({ success: true });
}), [buildNewEventPayload, dispatch, onSaveExternal, onSaveAndCompleteEnrollmentSuccessActionType, onSaveSuccessActionType, onSaveAndCompleteEnrollmentErrorActionType, onSaveErrorActionType]);

const handleCreateNew = useCallback(async (isCreateNew?: boolean) => {
try {
await handleSave(itemId, dataEntryId, formFoundation, addEventSaveTypes.COMPLETE);

const saveResult = await handleSave(itemId, dataEntryId, formFoundation, addEventSaveTypes.COMPLETE);
if (saveResult?.success) {
dispatch(startCreateNewAfterCompleting({
enrollmentId,
isCreateNew,
Expand All @@ -142,8 +141,6 @@ export const Validated = ({
teiId,
availableProgramStages,
}));
} catch (error) {
// Related stages has displayed an error message. No need to do anything here.
}
}, [handleSave, formFoundation, dispatch, enrollmentId, orgUnit.id, program.id, teiId, availableProgramStages]);

Expand Down

0 comments on commit 4ebef85

Please sign in to comment.