"use client"; import { Turnstile } from "@marsidev/react-turnstile"; import { motion, useInView } from "framer-motion"; import { AlertCircle, CheckCircle2, Github, Linkedin, Mail, Send, Sparkles, } from "lucide-react"; import { useRef, useState } from "react"; const contactMethods = [ { icon: Mail, label: "Email", value: "contact@jessy-david.dev", href: "mailto:contact@jessy-david.dev", color: "from-blue-500 to-cyan-500", }, { icon: Github, label: "GitHub", value: "@jessydavid", href: "https://github.com/jessydavid-dev", color: "from-slate-700 to-slate-900", }, { icon: Linkedin, label: "LinkedIn", value: "Jessy David", href: "https://linkedin.com/in/jessy-david", color: "from-blue-600 to-blue-800", }, ]; export default function Contact() { const ref = useRef(null); const isInView = useInView(ref, { once: false, amount: 0.2 }); const [isSubmitted, setIsSubmitted] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false); const [error, setError] = useState(""); const [captchaToken, setCaptchaToken] = useState(""); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); const form = e.currentTarget; setIsSubmitting(true); setError(""); setIsSubmitted(false); if (!captchaToken) { setError("Veuillez valider le captcha"); setIsSubmitting(false); return; } const formData = new FormData(form); const data = { name: formData.get("name") as string, email: formData.get("email") as string, message: formData.get("message") as string, captchaToken, }; try { const response = await fetch("/api/contact", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(data), }); if (!response.ok) { const result = await response.json(); throw new Error(result.error || "Erreur lors de l'envoi"); } const result = await response.json(); console.log("Succès:", result); setIsSubmitted(true); form.reset(); setCaptchaToken(""); setTimeout(() => setIsSubmitted(false), 5000); } catch (err) { console.error("Erreur:", err); setError( err instanceof Error ? err.message : "Impossible d'envoyer le message." ); setCaptchaToken(""); } finally { setIsSubmitting(false); } }; return (
{/* Grid Background */}
{/* Decorative blobs */}
{/* Header */}
Entrons en contact

Contactez-moi

Un projet en tête ? Une question ? N'hésitez pas à me contacter

{/* Colonne de gauche - Méthodes de contact */} {/* Cartes de contact */}
{contactMethods.map((method, index) => (

{method.label}

{method.value}

))}
{/* Informations complémentaires */}
{/* Effet ping */} {/* Pastille fixe */}

Disponibilité

Actuellement disponible pour vos projets.

{/* Colonne de droite - Formulaire de contact */}
{/* Cloudflare Turnstile */}
setCaptchaToken(token) } onError={() => setCaptchaToken("")} onExpire={() => setCaptchaToken("")} options={{ theme: "dark", size: "normal", }} />
{/* Message d'erreur */} {error && ( {error} )} {/* Message de succès */} {isSubmitted && ( Message envoyé avec succès ! Je vous répondrai bientôt. )}
); }