'use client'; import { useState } from 'react'; import { motion } from 'framer-motion'; import { useLocale } from '@/lib/i18n/locale-context'; import { SectionHeader } from '@/components/ui/SectionHeader'; import { SERVICE_IDS } from '@/lib/i18n/dictionaries'; import { cn } from '@/lib/utils'; type Status = 'idle' | 'sending' | 'sent' | 'error'; export function Contact() { const { t, locale } = useLocale(); const [status, setStatus] = useState('idle'); const [error, setError] = useState(null); async function onSubmit(e: React.FormEvent) { e.preventDefault(); setStatus('sending'); setError(null); const form = e.currentTarget; const data = Object.fromEntries(new FormData(form).entries()); try { const res = await fetch('/api/contact', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ ...data, locale }), }); if (!res.ok) { const body = await res.json().catch(() => ({})); throw new Error(body?.error ?? `HTTP ${res.status}`); } setStatus('sent'); form.reset(); } catch (err) { setStatus('error'); setError(err instanceof Error ? err.message : 'Unknown error'); } } return (