"use client"; import { useState } from "react"; import MagicReveal from "@/components/ui/MagicReveal"; import Button from "@/components/ui/Button"; interface MaconClientProps { type?: "slider" | "form" | "faq" | "floating"; avantLabel?: string; apresLabel?: string; avantImage?: string; apresImage?: string; faqs?: { q: string; a: string }[]; } export default function MaconClient({ type, avantLabel, apresLabel, avantImage, apresImage, faqs, }: MaconClientProps) { if (type === "slider") { return ( ); } if (type === "form") { return ; } if (type === "faq") { return ; } if (type === "floating") { return ; } return null; } /* ============================================================ FAQ ACCORDION ============================================================ */ function FaqAccordion({ faqs }: { faqs: { q: string; a: string }[] }) { const [openIdx, setOpenIdx] = useState(null); return (
{faqs.map((faq, i) => { const isOpen = openIdx === i; return (
{isOpen && (

{faq.a}

)}
); })}
); } /* ============================================================ SMART DEVIS FORM ============================================================ */ function DevisForm() { const [step, setStep] = useState<"type" | "details" | "done">("type"); const [projectType, setProjectType] = useState(""); const [fields, setFields] = useState({ name: "", phone: "", ville: "", description: "" }); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const updateField = (key: keyof typeof fields, value: string) => setFields((prev) => ({ ...prev, [key]: value })); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setError(null); try { const res = await fetch("/api/devis", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ ...fields, projectType }), }); if (!res.ok) { const data = await res.json(); throw new Error(data.error || "Erreur lors de l'envoi"); } setStep("done"); } catch (err) { setError(err instanceof Error ? err.message : "Erreur inattendue"); } finally { setLoading(false); } }; if (step === "done") { return (

Demande envoyée !

Nous vous recontactons sous 24h pour votre devis.

); } if (step === "details") { return (
2/2

Vos coordonnées

Projet : {projectType}

updateField("name", e.target.value)} className="w-full px-4 py-3 bg-[#f8f6f3] border border-gray-200 rounded-xl text-text text-sm placeholder:text-text-muted focus:border-orange focus:ring-1 focus:ring-orange outline-none" />
updateField("phone", e.target.value)} className="w-full px-4 py-3 bg-[#f8f6f3] border border-gray-200 rounded-xl text-text text-sm placeholder:text-text-muted focus:border-orange focus:ring-1 focus:ring-orange outline-none" />
updateField("ville", e.target.value)} className="w-full px-4 py-3 bg-[#f8f6f3] border border-gray-200 rounded-xl text-text text-sm placeholder:text-text-muted focus:border-orange focus:ring-1 focus:ring-orange outline-none" />