"use client"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Textarea } from "@/components/ui/textarea"; import { API_URL } from "@/lib/constants"; import { ApiResponse } from "@/types/types"; import { useEffect, useState } from "react"; interface FormData { firstname: string; lastname: string; email: string; subject: string; message: string; } const Contact = () => { const [formData, setFormData] = useState({ firstname: "", lastname: "", subject: "", email: "", message: "", }); const [csrfToken, setCsrfToken] = useState(""); const handleChange = ( e: React.ChangeEvent, ) => { console.log(e.currentTarget); setFormData({ ...formData, [e.currentTarget.name]: e.currentTarget.value, }); }; useEffect(() => { const fetchCsrfToken = async () => { try { const response = await fetch(`${API_URL}/csrf-token`, { credentials: "include", }); const data: ApiResponse<{ csrf: string }> = await response.json(); if (data.data) setCsrfToken(data.data.csrf); } catch (e: any) { console.log(e); } }; fetchCsrfToken(); }, []); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); const res = await fetch(`${API_URL}/contact`, { headers: { "Content-Type": "application/json", "X-CSRF-Token": csrfToken, }, method: "POST", body: JSON.stringify(formData), credentials: "include", }); }; return (

Contactez-nous !

Nous nous rendons disponible pour répondre à toutes vos questions.

Informations de contact