diff --git a/src/components/contact-form.tsx b/src/components/contact-form.tsx deleted file mode 100644 index d8615df..0000000 --- a/src/components/contact-form.tsx +++ /dev/null @@ -1,105 +0,0 @@ -import {Turnstile} from '@marsidev/react-turnstile'; -import {useState} from 'react'; -import toast from 'react-hot-toast'; - -export function ContactForm() { - const [submitted, setSubmitted] = useState(false); - const [loading, setLoading] = useState(false); - - if (submitted) { - return ( -
-

Message received

-

I'll get back to you as soon as possible

-
- ); - } - - return ( - <> -
-

Let's talk 📬

-

- Drop me a message with the form below, I'll get back to the non-spam -

-
- -
{ - event.preventDefault(); - - const values = Object.fromEntries( - new FormData(event.target as HTMLFormElement).entries(), - ); - - setLoading(true); - - const promise = fetch('/api/contact', { - headers: {'Content-Type': 'application/json'}, - body: JSON.stringify(values), - method: 'POST', - }); - - await toast - .promise(promise, { - success: 'Success!', - loading: 'Sending...', - error: (error: Error) => error?.message ?? 'Something went wrong...', - }) - .then(async () => { - setSubmitted(true); - }) - .catch(() => null) - .finally(() => { - setLoading(false); - }); - }} - method="POST" - action="/api/contact" - className="space-y-2 [&>label]:block [&_input]:rounded-md [&_textarea]:rounded-md" - > - - -