Skip to content

Commit db781cd

Browse files
committed
Fix modal not closing after submit
1 parent e3c154f commit db781cd

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

src/steps/ValidationStep/ValidationStep.tsx

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,28 @@ export const ValidationStep = <T extends string>({ initialData, file, onBack }:
100100
)
101101
setShowSubmitAlert(false)
102102
setSubmitting(true)
103-
onSubmit(calculatedData, file)
104-
?.then(() => {
105-
onClose()
106-
})
107-
.catch((err: Error) => {
108-
toast({
109-
status: "error",
110-
variant: "left-accent",
111-
position: "bottom-left",
112-
title: `${translations.alerts.submitError.title}`,
113-
description: err?.message || `${translations.alerts.submitError.defaultMessage}`,
114-
isClosable: true,
103+
const response = onSubmit(calculatedData, file)
104+
if (response?.then) {
105+
response
106+
.then(() => {
107+
onClose()
115108
})
116-
})
117-
.finally(() => {
118-
setSubmitting(false)
119-
})
109+
.catch((err: Error) => {
110+
toast({
111+
status: "error",
112+
variant: "left-accent",
113+
position: "bottom-left",
114+
title: `${translations.alerts.submitError.title}`,
115+
description: err?.message || `${translations.alerts.submitError.defaultMessage}`,
116+
isClosable: true,
117+
})
118+
})
119+
.finally(() => {
120+
setSubmitting(false)
121+
})
122+
} else {
123+
onClose()
124+
}
120125
}
121126
const onContinue = () => {
122127
const invalidData = data.find((value) => {

0 commit comments

Comments
 (0)