/* global React */ const { useState } = React; /* ── Form delivery ────────────────────────────────────────────── Paste your free Web3Forms access key below to receive booking requests automatically at yaro@pausa.pt (sign up at web3forms.com with that address — takes 1 minute). While this is empty the form gracefully falls back to opening a pre-filled email instead. */ const WEB3FORMS_KEY = "e1f43f3f-17b9-4164-a588-cc235cdb160d"; function BookingModal({ open, onClose }) { const [sent, setSent] = useState(false); const [sending, setSending] = useState(false); const [errs, setErrs] = useState({}); const [vals, setVals] = useState({ name: "", email: "", company: "", size: "", note: "" }); function set(k, v) { setVals((s) => ({ ...s, [k]: v })); } function validate() { const e = {}; if (!vals.name.trim()) e.name = "Please tell us your name."; if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(vals.email)) e.email = "Enter a valid work email."; if (!vals.company.trim()) e.company = "Your company, please."; if (!vals.size) e.size = "Select a team size."; setErrs(e); return Object.keys(e).length === 0; } function mailtoFallback() { const subject = `Discovery call request — ${vals.company || vals.name}`; const body = [ `Name: ${vals.name}`, `Work email: ${vals.email}`, `Company: ${vals.company}`, `Leadership team size: ${vals.size}`, vals.note ? `Notes: ${vals.note}` : null, "", "— Sent from the Pausa landing page.", ].filter((l) => l !== null).join("\n"); window.location.href = `mailto:yaro@pausa.pt?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`; } async function submit(ev) { ev.preventDefault(); if (!validate()) return; // No key configured → open a pre-filled email instead. if (!WEB3FORMS_KEY) { mailtoFallback(); setSent(true); return; } setSending(true); try { const res = await fetch("https://api.web3forms.com/submit", { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json" }, body: JSON.stringify({ access_key: WEB3FORMS_KEY, subject: `Discovery call request — ${vals.company || vals.name}`, from_name: "Pausa landing page", name: vals.name, email: vals.email, company: vals.company, team_size: vals.size, message: vals.note || "(no extra notes)", }), }); const data = await res.json(); if (data.success) { setSent(true); } else { mailtoFallback(); setSent(true); } } catch (err) { mailtoFallback(); setSent(true); } finally { setSending(false); } } function close() { onClose(); // reset shortly after the close transition setTimeout(() => { setSent(false); setErrs({}); setVals({ name: "", email: "", company: "", size: "", note: "" }); }, 400); } return (
{ if (e.target === e.currentTarget) close(); }}>
{sent ? (

Thank you, {vals.name.split(" ")[0]}.

We've got your details and will reply within one working day. If an email draft opened instead, just hit send. You can also write us directly at yaro@pausa.pt.

) : (
Discovery call

Book a 30-minute conversation.

Tell us a little about your team and we'll find a time. No high-pressure sales.

set("name", e.target.value)} placeholder="Maria Silva" /> {errs.name}
set("email", e.target.value)} placeholder="maria@company.com" /> {errs.email}
set("company", e.target.value)} placeholder="Your company" /> {errs.company}
{errs.size}
)}
); } Object.assign(window, { BookingModal });