// Auteur : Simon-Pierre Boucher — contact@spboucher.ai "use client"; import { useState } from "react"; import { useLang } from "./LangContext"; export default function LeadForm({ unitId, estimate, }: { unitId: string | null; estimate: number; }) { const { t } = useLang(); const [email, setEmail] = useState(""); const [done, setDone] = useState(false); const [err, setErr] = useState(false); const submit = async (e: React.FormEvent) => { e.preventDefault(); setErr(false); const res = await fetch("/api/lead", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email, unitId, estimate }), }); if (res.ok) setDone(true); else setErr(true); }; if (done) return (
✓ {t("leadOk")}
); return ( ); }