// Composant temporaire pour déboguer l'API salarié // À utiliser uniquement en développement "use client"; import { useState } from "react"; import { api } from "@/lib/fetcher"; export default function DebugSalarieAPI() { const [matricule, setMatricule] = useState(""); const [result, setResult] = useState(null); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const testAPI = async () => { if (!matricule.trim()) { setError("Veuillez entrer un matricule"); return; } setLoading(true); setError(""); setResult(null); try { // Test avec debug=1 pour voir les infos de session console.log("🔍 Testing API with debug mode..."); const debugResult = await api(`/salaries/${matricule}?debug=1`); console.log("Debug result:", debugResult); // Test normal console.log("🔍 Testing normal API call..."); const normalResult = await api(`/salaries/${matricule}`); console.log("Normal result:", normalResult); setResult({ debug: debugResult, normal: normalResult, rawResponse: normalResult }); } catch (err: any) { console.error("❌ API Error:", err); setError(err.message || "Erreur inconnue"); } finally { setLoading(false); } }; return (

Debug API Salarié

setMatricule(e.target.value)} placeholder="Matricule du salarié (ex: SAL001)" className="flex-1 px-3 py-2 border rounded-lg" />
{error && (

Erreur:

{error}
)} {result && (

Debug Info:

                {JSON.stringify(result.debug, null, 2)}
              

Données retournées:

                {JSON.stringify(result.normal, null, 2)}
              

Structure des données:

    {result.normal && Object.keys(result.normal).map((key: string) => (
  • {key}: {typeof result.normal[key]} {result.normal[key] && ` = ${JSON.stringify(result.normal[key]).substring(0, 100)}${JSON.stringify(result.normal[key]).length > 100 ? '...' : ''}`}
  • ))}
)}
); }