"use client"; import { useState } from "react"; const typesProjets = [ "Construction de maison", "Rénovation", "Assainissement", "Création d'accès", "Démolition", "Autre", ]; export default function ContactForm() { const [form, setForm] = useState({ nom: "", telephone: "", email: "", typeProjet: "", description: "", budget: "", zone: "", }); const [status, setStatus] = useState<"idle" | "sending" | "success" | "error">("idle"); const [error, setError] = useState(""); const handleChange = ( e: React.ChangeEvent ) => { setForm((prev) => ({ ...prev, [e.target.name]: e.target.value })); }; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!form.nom || !form.telephone || !form.typeProjet) { setError("Merci de renseigner au minimum votre nom, téléphone et type de projet."); return; } setError(""); setStatus("sending"); try { const res = await fetch("/api/contact", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(form), }); if (res.ok) { setStatus("success"); setForm({ nom: "", telephone: "", email: "", typeProjet: "", description: "", budget: "", zone: "" }); } else { setStatus("error"); } } catch { setStatus("error"); } }; if (status === "success") { return (

Demande envoyée !

Benoît vous rappelle sous 24h. En cas d'urgence :{" "} 06 74 45 30 89

); } const ic = "w-full border border-border bg-bg-white px-4 py-3 text-sm text-text focus:outline-none focus:border-orange transition-colors"; const lc = "block text-xs font-bold uppercase tracking-widest text-navy mb-2"; return (