diff --git a/src/blocks/ContactForm/component.tsx b/src/blocks/ContactForm/component.tsx index ffea49a..ed346b2 100644 --- a/src/blocks/ContactForm/component.tsx +++ b/src/blocks/ContactForm/component.tsx @@ -35,16 +35,12 @@ export const ContactForm = (props: Props) => { const formData = new FormData(e.currentTarget) - console.log('...', [...formData.entries()]) - console.log('not spread', Object.entries(formData)) - const dataToSend = [...formData.entries()].map(([name, value]) => { return { field: name, value, } }) - console.log('datatosend', dataToSend) try { const submitResponse = await fetch('/api/form-submissions', { @@ -57,13 +53,11 @@ export const ContactForm = (props: Props) => { submissionData: dataToSend, }), }) - console.log(submitResponse) if (submitResponse.status !== 201) { setFormState('idle') toast('There was an issue with your submission. Please try again.') } else setFormState('success') } catch (err) { - console.log(err) setFormState('idle') toast('There was an issue with your submission. Please try again.') } @@ -136,8 +130,8 @@ export const ContactForm = (props: Props) => { } successChild={ } /> diff --git a/src/components/ContactForm.tsx b/src/components/ContactForm.tsx deleted file mode 100644 index 191bbe9..0000000 --- a/src/components/ContactForm.tsx +++ /dev/null @@ -1,104 +0,0 @@ -'use client' - -import { useEffect, useState } from 'react' -import { - PopoverForm, - PopoverFormButton, - PopoverFormCutOutLeftIcon, - PopoverFormCutOutRightIcon, - PopoverFormSeparator, - PopoverFormSuccess, -} from './popover-form' - -type FormState = 'idle' | 'loading' | 'success' - -const ContactForm = () => { - const [formState, setFormState] = useState('idle') - const [open, setOpen] = useState(false) - const [feedback, setFeedback] = useState('') - - function submit() { - setFormState('loading') - setTimeout(() => { - setFormState('success') - }, 1500) - - setTimeout(() => { - setOpen(false) - setFormState('idle') - setFeedback('') - }, 3300) - } - - useEffect(() => { - const handleKeyDown = (event: KeyboardEvent) => { - if (event.key === 'Escape') { - setOpen(false) - } - - if ( - (event.ctrlKey || event.metaKey) && - event.key === 'Enter' && - open && - formState === 'idle' - ) { - submit() - } - } - - window.addEventListener('keydown', handleKeyDown) - return () => window.removeEventListener('keydown', handleKeyDown) - }, [open, formState]) - - return ( - - { - e.preventDefault() - if (!feedback) return - submit() - }} - > - - setFeedback(e.target.value)} - className="h-32 w-full resize-none rounded-t-lg p-3 text-sm outline-none" - required - /> - - - - - - - - - - - - - } - successChild={ - - } - /> - - ) -} - -export default ContactForm