diff --git a/src/components/Page/Page.tsx b/src/components/Page/Page.tsx index 23f437ce..90605bab 100644 --- a/src/components/Page/Page.tsx +++ b/src/components/Page/Page.tsx @@ -13,6 +13,7 @@ const Page = ({ children, title, 'data-cy': dataCy }: PageProps) => { sx={{ color: '#60718c', maxHeight: '55vh', + width: '100%', overflowY: 'auto', gap: '2.5rem' }} diff --git a/src/components/Pages/Contact.tsx b/src/components/Pages/Contact.tsx index 7c2b711d..37667487 100644 --- a/src/components/Pages/Contact.tsx +++ b/src/components/Pages/Contact.tsx @@ -1,42 +1,191 @@ import { useState } from 'react'; -import { Box, CircularProgress } from '@mui/material'; +import { + Checkbox, + Stack, + Button, + FormControlLabel, + Alert, + Collapse, + Typography +} from '@mui/material'; +import { FormProvider, useForm, Controller } from 'react-hook-form'; +import { zodResolver } from '@hookform/resolvers/zod'; +import { addFeedback } from 'services/db'; +import Page from 'components/Page/Page'; +import feedbackFormSchema, { + type FeedbackFormValues +} from 'schemas/feedbackFormSchema'; +import FormTextField from 'components/forms/FormTextField/FormTextField'; +import ClearFormIcon from 'icons/ClearFormIcon'; + +type FormValues = FeedbackFormValues; + +const TITLE = 'Contact Us'; +const PRIMARY_COLOR = '#10b6ff'; +const textFieldFocus = { + '& .MuiOutlinedInput-root': { + '&.Mui-focused fieldset': { + borderColor: PRIMARY_COLOR + } + }, + '& .MuiInputLabel-root.Mui-focused': { + color: PRIMARY_COLOR + } +}; +const SCHEMA = feedbackFormSchema; const Contact = () => { - const [loading, setLoading] = useState(true); + const [status, setStatus] = useState<'idle' | 'success' | 'error'>('idle'); + + const methods = useForm({ + defaultValues: { + name: '', + email: '', + feedback: '', + interest: false + }, + resolver: zodResolver(SCHEMA) + }); + + const { + handleSubmit, + control, + reset, + formState: { isSubmitting } + } = methods; + + const onSubmit = async (data: FormValues) => { + setStatus('idle'); + try { + await addFeedback(data); + setStatus('success'); + reset(); + } catch (error) { + console.error(error); + setStatus('error'); + } + }; - const handleLoading = () => { - setLoading(false); + const handleClear = () => { + reset(); + setStatus('idle'); }; return ( - - {loading && ( - - - - )} - -