'use client' import { useState } from 'react' type Status = 'idle' | 'loading' | 'done' | 'error' const CATEGORIES = [ { value: 'BUG', label: 'Bug report' }, { value: 'FEATURE_REQUEST', label: 'Feature request' }, { value: 'GENERAL', label: 'General feedback' }, ] export function FeedbackForm({ onSuccess, autoFocus = false }: { onSuccess?: () => void; autoFocus?: boolean }) { const [category, setCategory] = useState('BUG') const [message, setMessage] = useState('') const [email, setEmail] = useState('') const [status, setStatus] = useState('idle') async function handleSubmit(e: React.FormEvent) { e.preventDefault() if (!message.trim()) return setStatus('loading') try { const res = await fetch('/api/feedback', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ category, message: message.trim(), email: email.trim() || undefined, }), }) if (res.ok) { setStatus('done') onSuccess?.() } else { setStatus('error') } } catch { setStatus('error') } } if (status === 'done') { return (

Thanks — we got it.

We read everything. If you left an email we'll follow up.

) } return (
setEmail(e.target.value)} placeholder="you@email.com" disabled={status === 'loading'} className="w-full rounded-lg border border-zinc-800 bg-zinc-950 px-3 py-2.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-amber-500/40 focus:outline-none disabled:opacity-50" />