From cb2a110ae59636daa19321bac912eebec8520636 Mon Sep 17 00:00:00 2001 From: Michael Hunteman Date: Sat, 2 Mar 2024 10:33:48 -0800 Subject: Fix form validation --- src/features/auth/GuestLogin.tsx | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/features/auth/GuestLogin.tsx') diff --git a/src/features/auth/GuestLogin.tsx b/src/features/auth/GuestLogin.tsx index 1f228d8..cbab494 100644 --- a/src/features/auth/GuestLogin.tsx +++ b/src/features/auth/GuestLogin.tsx @@ -10,8 +10,7 @@ function GuestLogin() { const navigate = useNavigate(); const [login] = useLoginMutation(); - const { register, handleSubmit, - formState: { isDirty, isValid } } = useForm({ + const { register, handleSubmit, formState: { errors } } = useForm({ defaultValues: { firstName: '', lastName: '' @@ -29,7 +28,12 @@ function GuestLogin() { return ( - + Guest Login @@ -38,24 +42,26 @@ function GuestLogin() { variant="outlined" margin="normal" fullWidth - required - {...register("firstName", { required: true })} + error={!!errors.firstName} + helperText={errors.firstName?.message} + {...register("firstName", { required: "Please enter your first name" })} /> -- cgit v1.2.3