'use client'; import { useState } from 'react'; export default function ContactForm() { const [state, setState] = useState<'idle' | 'sending' | 'sent' | 'error'>('idle'); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); const data = new FormData(e.currentTarget); setState('sending'); try { const res = await fetch('/api/contact', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: data.get('email'), topic: data.get('topic'), url: data.get('url'), message: data.get('message'), }), }); setState(res.ok ? 'sent' : 'error'); } catch { setState('error'); } } if (state === 'sent') { return (
Thanks — your message has been queued. For time-sensitive legal notices, also email the address listed on the site.
); } return (