summaryrefslogtreecommitdiff
path: root/src/components/RsvpForm.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/RsvpForm.tsx')
-rw-r--r--src/components/RsvpForm.tsx23
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>