Skip to content

Commit

Permalink
separate abort flow from continue flow
Browse files Browse the repository at this point in the history
  • Loading branch information
lkleuver committed Mar 5, 2025
1 parent 6cc4f8a commit d225222
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions frontend/app/component/form/data_entry/DataEntryNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ export function DataEntryNavigation({ onSubmit, currentValues }: DataEntryNaviga
return null;
}

const onModalSave = async () => {
if (await onSubmit({ aborting: false, continueToNextSection: true, showAcceptWarnings: false })) {
blocker.proceed();
} else {
blocker.reset();
}
};
// when save is chosen in the abort dialog
const onAbortModalSave = async () => {
if (await onSubmit({ aborting: true, continueToNextSection: false, showAcceptWarnings: false })) {
Expand All @@ -67,7 +74,7 @@ export function DataEntryNavigation({ onSubmit, currentValues }: DataEntryNaviga
}
};

const onAbortModalDoNoSave = () => {
const onModalDoNoSave = () => {
updateFormSection({ hasChanges: false });
blocker.proceed();
};
Expand All @@ -94,7 +101,7 @@ export function DataEntryNavigation({ onSubmit, currentValues }: DataEntryNaviga
size="lg"
type="button"
onClick={() => {
void onAbortModalSave();
void onModalSave();
}}
>
{t("save_changes")}
Expand All @@ -104,7 +111,7 @@ export function DataEntryNavigation({ onSubmit, currentValues }: DataEntryNaviga
variant="secondary"
type="button"
onClick={() => {
onAbortModalDoNoSave();
onModalDoNoSave();
}}
>
{t("do_not_save")}
Expand Down

0 comments on commit d225222

Please sign in to comment.