/** * Trouve-KA — dashboard admin (vue d'ensemble + contrôles + flux live) * Author: Simon-Pierre Boucher * Contact: contact@spboucher.ai */ "use client"; import Link from "next/link"; import { useCallback, useEffect, useState } from "react"; import { Controls } from "@/components/admin/controls"; import { HttpBars } from "@/components/admin/http-bars"; import { LiveFeed } from "@/components/admin/live-feed"; import { RecentErrors } from "@/components/admin/recent-errors"; import { TopDomains } from "@/components/admin/top-domains"; import { Stat } from "@/components/stat"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { adminFetch, UnauthorizedError } from "@/lib/admin"; import { formatNumber } from "@/lib/format"; import type { AdminOverview } from "@/lib/types"; const REFRESH_MS = 10_000; interface AdminDashboardProps { token: string; onUnauthorized: () => void; onLogout: () => void; } export function AdminDashboard({ token, onUnauthorized, onLogout, }: AdminDashboardProps) { const [overview, setOverview] = useState(null); const [error, setError] = useState(false); const refresh = useCallback(async () => { try { const data = await adminFetch( "/api/admin/overview", token, ); setOverview(data); setError(false); } catch (err) { if (err instanceof UnauthorizedError) { onUnauthorized(); return; } setError(true); } }, [token, onUnauthorized]); useEffect(() => { refresh(); const id = setInterval(refresh, REFRESH_MS); return () => clearInterval(id); }, [refresh]); return (
Trouve-KA /

Administration

{overview ? ( overview.paused ? ( En pause ) : ( ) ) : null}
{error && !overview ? (

Impossible de joindre l'API d'administration. Vérifiez que le backend tourne, puis rechargez la page.

) : null} {overview ? ( <>

Frontier

Débits (dernière heure)

) : !error ? (
); }