From fa1409d205479e9943f7b7db96a4b56ff1d29d7d Mon Sep 17 00:00:00 2001 From: Michael Hunteman Date: Wed, 28 Feb 2024 18:20:38 -0800 Subject: Resolve type errors --- src/components/Admin.tsx | 1 - src/components/NavBar.tsx | 5 ++--- src/components/Registry.tsx | 5 ++--- src/components/Rsvp.tsx | 4 +--- src/components/RsvpForm.tsx | 23 ++++++----------------- 5 files changed, 11 insertions(+), 27 deletions(-) (limited to 'src/components') diff --git a/src/components/Admin.tsx b/src/components/Admin.tsx index fac3306..76bf486 100644 --- a/src/components/Admin.tsx +++ b/src/components/Admin.tsx @@ -1,5 +1,4 @@ import { Paper, Typography } from '@mui/material'; - import { useGetGuestsQuery } from '../apiSlice'; function Admin() { diff --git a/src/components/NavBar.tsx b/src/components/NavBar.tsx index 68fc706..de40b4f 100644 --- a/src/components/NavBar.tsx +++ b/src/components/NavBar.tsx @@ -1,13 +1,12 @@ import { useContext } from 'react'; import { Link } from 'react-router-dom'; -import { AppBar, Box, Button, IconButton, Stack, Toolbar, Typography } from '@mui/material'; +import { AppBar, Button, IconButton, Stack, Toolbar, Typography } from '@mui/material'; import DarkModeIcon from '@mui/icons-material/DarkMode'; import LightModeIcon from '@mui/icons-material/LightMode'; import { useTheme } from '@mui/material/styles'; - import { ThemeContext } from '../ThemeContextProvider'; -function NavBar({ mode }) { +function NavBar() { const theme = useTheme(); const { toggleColorMode } = useContext(ThemeContext); diff --git a/src/components/Registry.tsx b/src/components/Registry.tsx index 8d7fff4..e4f6398 100644 --- a/src/components/Registry.tsx +++ b/src/components/Registry.tsx @@ -1,5 +1,4 @@ -import Paper from '@mui/material/Paper'; -import Typography from '@mui/material/Typography'; +import { Paper, Typography } from '@mui/material'; function Registry() { return ( @@ -8,7 +7,7 @@ function Registry() { Registry - ) + ); } export default Registry; diff --git a/src/components/Rsvp.tsx b/src/components/Rsvp.tsx index 466175e..1b26e2d 100644 --- a/src/components/Rsvp.tsx +++ b/src/components/Rsvp.tsx @@ -2,9 +2,7 @@ import { useMemo } from 'react'; import { useLocation, Navigate, Outlet } from 'react-router-dom'; import { useSelector } from 'react-redux'; import CssBaseline from '@mui/material/CssBaseline'; - import NavBar from './NavBar'; -import RsvpForm from './RsvpForm'; import { selectCurrentUser } from '../features/auth/authSlice'; const authenticate = () => { @@ -20,7 +18,7 @@ function Rsvp() { <> - + ) : ( 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}); }; -- cgit v1.2.3