"use client"; import Link from "next/link"; import { useEffect, useState } from "react"; import { usePathname } from "next/navigation"; type ContactData = { email?: string; linkedin?: string; github?: string; }; export default function ContactComponent() { const pathname = usePathname(); const onContactPage = pathname === "/contact"; const [data, setData] = useState(null); useEffect(() => { if (!onContactPage) return; // Essaye avec BACKEND_URL, sinon fallback vers une route locale hypothétique const backend = (process.env.BACKEND_URL as string) || "http://127.0.0.1:5000/api"; const url = backend ? `${backend}/contact` : "http://127.0.0.1:5000/api/contact"; fetch(url, { cache: "no-store" }) .then((res) => (res.ok ? res.json() : Promise.reject(new Error("fetch contact failed")))) .then((json) => setData(json)) .catch(() => setData(null)); }, [onContactPage]); // Si on n'est pas sur la page /contact => juste un lien if (!onContactPage) { return (
Me contacter
); } // Page /contact => liens + formulaire return (
{data?.linkedin ? ( LinkedIn ) : null} {data?.github ? ( GitHub ) : null} {data?.email ? ( Email direct ) : null}
{data?.email ? (