diff options
Diffstat (limited to 'client/src/components')
-rw-r--r-- | client/src/components/AdminLogin.tsx | 6 | ||||
-rw-r--r-- | client/src/components/GuestLogin.tsx | 6 | ||||
-rw-r--r-- | client/src/components/RsvpForm.tsx | 20 |
3 files changed, 16 insertions, 16 deletions
diff --git a/client/src/components/AdminLogin.tsx b/client/src/components/AdminLogin.tsx index 92e5335..4f53566 100644 --- a/client/src/components/AdminLogin.tsx +++ b/client/src/components/AdminLogin.tsx @@ -5,7 +5,7 @@ import { Button, Paper, TextField, Typography } from '@mui/material'; import { useForm } from 'react-hook-form'; import { setAdmin } from '../slices/auth/adminSlice'; import { useLoginAdminMutation } from '../slices/api/adminSlice'; -import type { AdminLoginRequest } from '../models'; +import type { Credentials } from '../models'; function GuestLogin() { const dispatch = useDispatch(); @@ -16,14 +16,14 @@ function GuestLogin() { register, handleSubmit, formState: { errors }, - } = useForm<AdminLoginRequest>({ + } = useForm<Credentials>({ defaultValues: { username: '', password: '', }, }); - const onSubmit = async (data: AdminLoginRequest) => { + const onSubmit = async (data: Credentials) => { try { dispatch(setAdmin(await login(data).unwrap())); navigate('/dashboard'); diff --git a/client/src/components/GuestLogin.tsx b/client/src/components/GuestLogin.tsx index 0e47384..f42c1d6 100644 --- a/client/src/components/GuestLogin.tsx +++ b/client/src/components/GuestLogin.tsx @@ -5,7 +5,7 @@ import { Button, Paper, TextField, Typography } from '@mui/material'; import { useForm } from 'react-hook-form'; import { setGuest } from '../slices/auth/guestSlice'; import { useLoginGuestMutation } from '../slices/api/guestSlice'; -import type { GuestLoginRequest } from '../slices/api/guestSlice'; +import type { Name } from '../models'; function GuestLogin() { const dispatch = useDispatch(); @@ -16,14 +16,14 @@ function GuestLogin() { register, handleSubmit, formState: { errors }, - } = useForm<GuestLoginRequest>({ + } = useForm<Name>({ defaultValues: { firstName: '', lastName: '', }, }); - const onSubmit = async (data: GuestLoginRequest) => { + const onSubmit = async (data: Name) => { try { dispatch(setGuest(await login(data).unwrap())); navigate('/rsvp'); diff --git a/client/src/components/RsvpForm.tsx b/client/src/components/RsvpForm.tsx index c7c30f4..b3ed3b3 100644 --- a/client/src/components/RsvpForm.tsx +++ b/client/src/components/RsvpForm.tsx @@ -37,10 +37,10 @@ const Status = ({ isError, setOpen }: StatusProps) => { }; function RsvpForm() { - const [updateGuest, { isLoading, isSuccess, isError, error }] = + const [updateGuest, { isLoading, isSuccess, isError }] = useUpdateGuestMutation(); const guest: Guest = useOutletContext(); - const previousPartySize = useRef(guest?.partySize - 1); + const previousPartySize = useRef(guest.partySize ?? 1 - 1); const [open, setOpen] = useState<boolean>(false); useEffect(() => { @@ -55,14 +55,14 @@ function RsvpForm() { formState: { errors }, } = useForm<Guest>({ defaultValues: { - id: guest?.id, - firstName: guest?.firstName, - lastName: guest?.lastName, - attendance: guest?.attendance, - email: guest?.email, - message: guest?.message, - partySize: guest?.partySize, - partyList: guest?.partyList, + id: guest.id, + firstName: guest.firstName, + lastName: guest.lastName, + attendance: guest.attendance, + email: guest.email, + message: guest.message, + partySize: guest.partySize, + partyList: guest.partyList, }, }); |