From 4ce3be9349b3a19bbc99b7bf783eafeec040b2f7 Mon Sep 17 00:00:00 2001 From: Michael Hunteman Date: Fri, 1 Mar 2024 10:51:06 -0800 Subject: Update formatting on forms --- package.json | 2 +- src/apiSlice.ts | 6 +- src/components/RsvpForm.tsx | 121 +++++++++++++++++---------------------- src/features/auth/GuestLogin.tsx | 21 +++++-- src/mocks/handlers.ts | 10 ++-- 5 files changed, 75 insertions(+), 85 deletions(-) diff --git a/package.json b/package.json index 1e340d2..0156564 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "0.0.0", "type": "module", "scripts": { - "dev": "vite", + "dev": "vite --host", "build": "tsc && vite build", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "preview": "vite preview" diff --git a/src/apiSlice.ts b/src/apiSlice.ts index 808806f..6a1196b 100644 --- a/src/apiSlice.ts +++ b/src/apiSlice.ts @@ -16,10 +16,8 @@ export interface Guest { firstName: string lastName: string attendance: string - meal: string - restrictions: string - plusOne: string - advice: string + email: string + message: string } export const apiSlice = createApi({ diff --git a/src/components/RsvpForm.tsx b/src/components/RsvpForm.tsx index 7beb21a..8c67139 100644 --- a/src/components/RsvpForm.tsx +++ b/src/components/RsvpForm.tsx @@ -1,5 +1,7 @@ import { + Box, Button, + Container, FormControl, FormControlLabel, FormLabel, @@ -17,17 +19,15 @@ function RsvpForm() { const [updateGuest] = useUpdateGuestMutation(); const guest: Guest = useOutletContext(); - const { register, handleSubmit, control, - formState: { errors } } = useForm({ + const { register, handleSubmit, control } = useForm({ defaultValues: { id: guest?.id, firstName: guest?.firstName, lastName: guest?.lastName, attendance: '', - meal: '', - restrictions: '', - plusOne: '', - advice: '' + email: '', + partySize: 1, + message: '' } }); @@ -36,8 +36,8 @@ function RsvpForm() { }; return ( -
- + + Date: April 14, 2025 @@ -47,82 +47,67 @@ function RsvpForm() { RSVP Deadline: - - - { errors && {errors.attendance?.message} } - Will you attend our wedding? - ( - - } - label="Yes" - /> - } - label="No" - /> - - )} - /> - - - - - { errors && {errors.meal?.message} } - Meal Preference - ( - - } - label="Beef" - /> - } - label="Chicken" - /> - - )} - /> + + + + Will you attend our wedding? + ( + + } + label="Yes" + /> + } + label="No" + /> + + )} + /> + - + - + - + - - + + + + - + ); } diff --git a/src/features/auth/GuestLogin.tsx b/src/features/auth/GuestLogin.tsx index 61a8fa1..1f228d8 100644 --- a/src/features/auth/GuestLogin.tsx +++ b/src/features/auth/GuestLogin.tsx @@ -1,6 +1,6 @@ import { useNavigate } from 'react-router-dom'; import { useDispatch } from 'react-redux'; -import { Button, Stack, TextField, Typography } from '@mui/material'; +import { Box, Button, Container, TextField, Typography } from '@mui/material'; import { useForm } from 'react-hook-form'; import { setCredentials } from './authSlice'; import { useLoginMutation, LoginRequest } from '../../apiSlice'; @@ -28,28 +28,37 @@ function GuestLogin() { }; return ( -
- + + Guest Login - - -
+ + ); } diff --git a/src/mocks/handlers.ts b/src/mocks/handlers.ts index 63b1a9a..6bd17fa 100644 --- a/src/mocks/handlers.ts +++ b/src/mocks/handlers.ts @@ -13,9 +13,8 @@ export const handlers = [ lastName: 'Hunteman', attendance: 'false', meal: '', - restrictions: '', - plusOne: '', - advice: '' + email: '', + message: '' }, token, } @@ -29,9 +28,8 @@ export const handlers = [ lastName: 'Hunteman', attendance: 'true', meal: 'beef', - restrictions: '', - plusOne: '', - advice: '' + email: '', + message: '' } ) }) -- cgit v1.2.3