Updated login form to disable the form when submitting

This commit is contained in:
Aaron William Po
2023-04-05 22:44:40 -04:00
parent 58c981a019
commit 38950390cd

View File

@@ -11,6 +11,7 @@ import FormInfo from '../ui/forms/FormInfo';
import FormLabel from '../ui/forms/FormLabel'; import FormLabel from '../ui/forms/FormLabel';
import FormSegment from '../ui/forms/FormSegment'; import FormSegment from '../ui/forms/FormSegment';
import FormTextInput from '../ui/forms/FormTextInput'; import FormTextInput from '../ui/forms/FormTextInput';
import Button from '../ui/forms/Button';
type LoginT = z.infer<typeof LoginValidationSchema>; type LoginT = z.infer<typeof LoginValidationSchema>;
const LoginForm = () => { const LoginForm = () => {
@@ -51,6 +52,7 @@ const LoginForm = () => {
id="username" id="username"
type="text" type="text"
formValidationSchema={register('username')} formValidationSchema={register('username')}
disabled={formState.isSubmitting}
error={!!errors.username} error={!!errors.username}
placeholder="username" placeholder="username"
/> />
@@ -62,6 +64,7 @@ const LoginForm = () => {
</FormInfo> </FormInfo>
<FormSegment> <FormSegment>
<FormTextInput <FormTextInput
disabled={formState.isSubmitting}
id="password" id="password"
type="password" type="password"
formValidationSchema={register('password')} formValidationSchema={register('password')}
@@ -73,9 +76,9 @@ const LoginForm = () => {
{responseError && <ErrorAlert error={responseError} setError={setResponseError} />} {responseError && <ErrorAlert error={responseError} setError={setResponseError} />}
<div className="w-full"> <div className="w-full">
<button type="submit" className="btn-primary btn w-full"> <Button type="submit" isSubmitting={formState.isSubmitting}>
Login Login
</button> </Button>
</div> </div>
</form> </form>
); );