summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorMichael Hunteman <michael@huntm.net>2024-02-28 18:20:38 -0800
committerMichael Hunteman <michael@huntm.net>2024-02-28 18:20:38 -0800
commitfa1409d205479e9943f7b7db96a4b56ff1d29d7d (patch)
tree4010f01003d679940f422e72e0e291f9582172d7 /src/components
parent064c11060f7a8e1ec5e1a128a7beabd7635991ca (diff)
Resolve type errors
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Admin.tsx1
-rw-r--r--src/components/NavBar.tsx5
-rw-r--r--src/components/Registry.tsx5
-rw-r--r--src/components/Rsvp.tsx4
-rw-r--r--src/components/RsvpForm.tsx23
5 files changed, 11 insertions, 27 deletions
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
</Typography>
</Paper>
- )
+ );
}
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() {
<>
<CssBaseline />
<NavBar />
- <Outlet />
+ <Outlet context={auth} />
</>
) : (
<Navigate to="/guest-login" state={{ from: location }} replace />
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});
};