// contact.jsx — Y2K contact form (conectado a /api/contact.php) const { useState: __cts, useEffect: __cte, useRef: __ctr } = React; function Contact({ t }) { const [form, setForm] = __cts({ name: '', email: '', company: '', budget: '', services: [], brief: '', website: '', // honeypot — debe quedar vacío }); const [submitted, setSubmitted] = __cts(false); const [sending, setSending] = __cts(false); const [errMsg, setErrMsg] = __cts(null); const csrf = __ctr(null); const loadedAt = __ctr(Math.floor(Date.now() / 1000)); // Pide token CSRF al montar __cte(() => { fetch('api/csrf.php', { credentials: 'same-origin' }) .then(r => r.json()) .then(d => { csrf.current = d.token; loadedAt.current = d.t || loadedAt.current; }) .catch(() => {}); }, []); const toggle = (s) => { setForm(f => ({ ...f, services: f.services.includes(s) ? f.services.filter(x => x !== s) : [...f.services, s] })); }; const submit = async (e) => { e.preventDefault(); if (sending) return; setErrMsg(null); setSending(true); try { const res = await fetch('api/contact.php', { method: 'POST', credentials: 'same-origin', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf.current || '' }, body: JSON.stringify({ ...form, _csrf: csrf.current, t: loadedAt.current }) }); const data = await res.json(); if (data.ok) { setSubmitted(true); } else { setErrMsg(data.msg || 'No pudimos enviar tu mensaje. Intenta de nuevo.'); } } catch (err) { setErrMsg('Error de conexión. Intenta de nuevo en un momento.'); } finally { setSending(false); } }; return (
{/* Left intro */}
{t.cnt_eye}

{t.cnt_title_1}
{t.cnt_title_2}

{t.cnt_sub}

{t.cnt_or}
hola@multiplesmedios.com
{[ { l: 'Instagram', h: '@multiplesmedios', c: 'magenta' }, { l: 'WhatsApp', h: '+57 300 000 0000', c: 'lime' }, { l: 'LinkedIn', h: '/multiplesmedios', c: 'azure' }, ].map(c => (
{c.l}
{c.h}
))}
{/* Right form */} {submitted ? (

Gracias, {form.name || 'amigo'}.

Respondemos en < 24 horas.

) : (
{/* Honeypot oculto (los bots la llenan, humanos no) */} {errMsg && (
{errMsg}
)}
setForm({...form, name: e.target.value})} />
setForm({...form, email: e.target.value})} />
setForm({...form, company: e.target.value})} />
{t.services_pick.map(s => ( ))}
{t.budgets.map(b => ( ))}