fix: signup form submiting after api error (#8298)

Co-authored-by: Omar López <zomars@me.com>
pull/8360/head
Joe 2023-04-18 07:28:54 +05:30 committed by GitHub
parent b1404356ff
commit 9dd36bd20e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

@ -95,7 +95,17 @@ export default function Signup({ prepopulateFormValues }: inferSSRProps<typeof g
<div className="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
<div className="bg-default mx-2 px-4 py-8 shadow sm:rounded-lg sm:px-10">
<FormProvider {...methods}>
<form onSubmit={methods.handleSubmit(signUp)} className="bg-default space-y-6">
<form
onSubmit={(event) => {
event.preventDefault();
event.stopPropagation();
if (methods.formState?.errors?.apiError) {
methods.clearErrors("apiError");
}
methods.handleSubmit(signUp)(event);
}}
className="bg-default space-y-6">
{errors.apiError && <Alert severity="error" message={errors.apiError?.message} />}
<div className="space-y-2">
<TextField