diff options
author | Michael Hunteman <michael@huntm.net> | 2024-03-01 07:44:28 -0800 |
---|---|---|
committer | Michael Hunteman <michael@huntm.net> | 2024-03-01 07:44:28 -0800 |
commit | 2b3d32a641da19c9d807f1877efcbe1a130c5e23 (patch) | |
tree | 040b0bdced188912e3fbbeafdb3d2cbbc784676f /src/components/RsvpForm.tsx | |
parent | fa1409d205479e9943f7b7db96a4b56ff1d29d7d (diff) |
Use guest for login and RSVP update
Diffstat (limited to 'src/components/RsvpForm.tsx')
-rw-r--r-- | src/components/RsvpForm.tsx | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/components/RsvpForm.tsx b/src/components/RsvpForm.tsx index 11ed376..7beb21a 100644 --- a/src/components/RsvpForm.tsx +++ b/src/components/RsvpForm.tsx @@ -11,26 +11,27 @@ import { } from '@mui/material'; import { useForm, Controller } from 'react-hook-form'; import { useOutletContext } from "react-router-dom"; -import { useUpdateGuestMutation, Guest, User } from '../apiSlice'; +import { useUpdateGuestMutation, Guest } from '../apiSlice'; function RsvpForm() { const [updateGuest] = useUpdateGuestMutation(); - const user: User = useOutletContext(); + const guest: Guest = useOutletContext(); const { register, handleSubmit, control, formState: { errors } } = useForm({ defaultValues: { - id: user.id, + id: guest?.id, + firstName: guest?.firstName, + lastName: guest?.lastName, attendance: '', - mealPreference: '', - dietaryRestrictions: '', + meal: '', + restrictions: '', plusOne: '', - marriageAdvice: '' + advice: '' } }); const onSubmit = async (data: Guest) => { - console.log(data); updateGuest({...data}); }; @@ -73,10 +74,10 @@ function RsvpForm() { </Grid> <Grid item xs={12} md={4} lg={4}> <FormControl> - { errors && <Typography>{errors.mealPreference?.message}</Typography> } + { errors && <Typography>{errors.meal?.message}</Typography> } <FormLabel>Meal Preference</FormLabel> <Controller - name="mealPreference" + name="meal" control={control} rules={{ required: "What would you like to eat?" }} render={({ field }) => ( @@ -100,7 +101,7 @@ function RsvpForm() { <TextField label="Dietary Restrictions" variant="outlined" - {...register("dietaryRestrictions")} + {...register("restrictions")} /> </Grid> <Grid item xs={12} md={4} lg={4}> @@ -114,7 +115,7 @@ function RsvpForm() { <TextField label="Marriage Advice" variant="outlined" - {...register("marriageAdvice")} + {...register("advice")} /> </Grid> <Grid item> |