// early-access-modal.jsx — Werkd isn't open for public sign-up yet. Every // former "Start trial / Sign up" CTA now opens this instead: a simple email // capture that POSTs to send-early-access.php (PHP mail(), works on // Hostinger shared hosting with no extra setup — see that file's header). // Open via window.dispatchEvent(new CustomEvent('werkd:open-early-access')). function EarlyAccessModal() { const DA = window.DA; const [open, setOpen] = React.useState(false); const [email, setEmail] = React.useState(''); const [company, setCompany] = React.useState(''); // honeypot — left blank by humans const [sent, setSent] = React.useState(false); const [submitting, setSubmitting] = React.useState(false); const [error, setError] = React.useState(''); const inputRef = React.useRef(null); React.useEffect(() => { const onOpen = () => { setOpen(true); setSent(false); setEmail(''); setError(''); setSubmitting(false); }; window.addEventListener('werkd:open-early-access', onOpen); return () => window.removeEventListener('werkd:open-early-access', onOpen); }, []); React.useEffect(() => { if (!open) return; const onKey = (e) => { if (e.key === 'Escape') setOpen(false); }; window.addEventListener('keydown', onKey); const prevOverflow = document.body.style.overflow; document.body.style.overflow = 'hidden'; const t = setTimeout(() => inputRef.current && inputRef.current.focus(), 60); return () => { window.removeEventListener('keydown', onKey); document.body.style.overflow = prevOverflow; clearTimeout(t); }; }, [open]); if (!open) return null; const submit = async (e) => { e.preventDefault(); if (!email.trim() || submitting) return; setSubmitting(true); setError(''); try { const res = await fetch('send-early-access.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email, company }), }); const data = await res.json().catch(() => null); if (res.ok && data && data.ok) { setSent(true); } else { setError((data && data.error) || 'Something went wrong — please try again.'); } } catch { setError('Could not reach the server — please try again, or email contact@werkd.pro directly.'); } finally { setSubmitting(false); } }; const modal = (
Thanks — we'll reach out as soon as werkd opens up.
) : (Werkd isn't open for sign-ups yet. Leave your email and we'll let you know the moment it is.
{error && ({error}
)}