Skip to content

Commit fa7c669

Browse files
authored
Prevent Scan Report Upload button from submitting multiple times (#1274)
1 parent 0126c41 commit fa7c669

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

app/next-client-app/components/scanreports/CreateScanReportForm.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,14 @@ export function CreateScanReportForm({
137137
validationSchema={validationSchema}
138138
validateOnChange={false}
139139
validateOnBlur={false}
140-
onSubmit={(data) => {
140+
onSubmit={async (data) => {
141+
// Return a Promise so Formik sets isSubmitting and prevents submitting multiple times
141142
toast.info("Validating and uploading...");
142-
handleSubmit(data);
143+
await handleSubmit(data);
143144
}}
144145
>
145-
{({ values, handleChange, handleSubmit, setFieldValue }) => (
146+
{({ values, handleChange, handleSubmit, setFieldValue, isSubmitting }) => (
147+
// added isSubmitting to the form to disable the submit button while upload is in progress
146148
<form
147149
className="w-full max-w-2xl"
148150
onSubmit={handleSubmit}
@@ -365,6 +367,7 @@ export function CreateScanReportForm({
365367
<Button
366368
type="submit"
367369
disabled={
370+
isSubmitting ||
368371
values.dataPartner === 0 ||
369372
values.dataset === 0 ||
370373
values.dataset === -1 ||

0 commit comments

Comments
 (0)