Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [DHIS2-18355] runtime error occurs when saving empty widget in Related stages #3935

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading