diff options
Diffstat (limited to 'src/components/RsvpForm.tsx')
-rw-r--r-- | src/components/RsvpForm.tsx | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/src/components/RsvpForm.tsx b/src/components/RsvpForm.tsx index 5e0fb31..11ed376 100644 --- a/src/components/RsvpForm.tsx +++ b/src/components/RsvpForm.tsx @@ -1,37 +1,26 @@ -import { useState } from 'react'; -import { useSelector } from 'react-redux'; import { Button, FormControl, FormControlLabel, FormLabel, Grid, - MenuItem, - Select, Radio, RadioGroup, TextField, Typography } from '@mui/material'; import { useForm, Controller } from 'react-hook-form'; -import { DevTool } from '@hookform/devtools'; - -import { useGetGuestsQuery, useUpdateGuestMutation } from '../apiSlice'; +import { useOutletContext } from "react-router-dom"; +import { useUpdateGuestMutation, Guest, User } from '../apiSlice'; function RsvpForm() { - const { - data: guests, - isLoading, - isSuccess, - isError, - error - } = useGetGuestsQuery(); - const [updateGuest] = useUpdateGuestMutation(); + const user: User = useOutletContext(); const { register, handleSubmit, control, - formState: { isDirty, isValid, errors } } = useForm({ + formState: { errors } } = useForm({ defaultValues: { + id: user.id, attendance: '', mealPreference: '', dietaryRestrictions: '', @@ -40,7 +29,7 @@ function RsvpForm() { } }); - const onSubmit = async (data) => { + const onSubmit = async (data: Guest) => { console.log(data); updateGuest({...data}); }; |