"use client"; import { useState } from "react"; import { CONSENT_TEXT, ACKNOWLEDGMENT_TEXT } from "@/lib/consent"; type Status = "idle" | "submitting" | "success" | "error"; const FIELD = "w-full rounded-control border border-line bg-card px-3.5 py-2.5 text-[15px] text-ink placeholder:text-ink-faint transition-colors focus:border-terracotta"; const LABEL = "block text-[13px] font-medium text-ink-soft mb-1.5"; export default function ContactForm() { const [fullName, setFullName] = useState(""); const [companyName, setCompanyName] = useState(""); const [role, setRole] = useState(""); const [email, setEmail] = useState(""); const [consentGiven, setConsentGiven] = useState(false); const [consentAcknowledged, setConsentAcknowledged] = useState(false); const [website, setWebsite] = useState(""); // honeypot const [status, setStatus] = useState("idle"); const [error, setError] = useState(""); const canSubmit = fullName.trim() && companyName.trim() && role.trim() && email.trim() && consentGiven && consentAcknowledged && status !== "submitting"; async function handleSubmit() { setStatus("submitting"); setError(""); try { const res = await fetch("/api/lead", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ fullName, companyName, role, email, consentGiven, consentAcknowledged, website, }), }); const data = await res.json(); if (!res.ok) { setError(data.error ?? "Something went wrong. Please try again."); setStatus("error"); return; } setStatus("success"); } catch { setError("Network error. Please try again."); setStatus("error"); } } if (status === "success") { return (

Thank you.

We've got your details and will be in touch shortly.

); } return (
setFullName(e.target.value)} autoComplete="name" />
setCompanyName(e.target.value)} autoComplete="organization" />
setRole(e.target.value)} autoComplete="organization-title" />
setEmail(e.target.value)} autoComplete="email" />
{/* Honeypot — visually hidden, off the tab order */}
setWebsite(e.target.value)} />
{status === "error" && (
{error}
)}
); }