import Link from "next/link"; import { MonthlyRevenueChart } from "@/components/analytics/MonthlyRevenueChart"; import { getAdminGlobalKpis, getMonthlyRevenueSeries } from "@/lib/analytics"; export const dynamic = "force-dynamic"; export const metadata = { title: "Analytics globaux — Karbé admin" }; const ROLE_LABEL: Record = { ADMIN: "Admin", OWNER: "Hôte", RENTAL_PROVIDER: "Loueur matériel", CE_MANAGER: "CE Manager", CE_MEMBER: "CE Membre", TOURIST: "Voyageur", }; function fmtEur(n: number): string { return n.toLocaleString("fr-FR", { style: "currency", currency: "EUR", maximumFractionDigits: 0 }); } export default async function AdminAnalyticsPage() { const [kpis, series] = await Promise.all([ getAdminGlobalKpis(), getMonthlyRevenueSeries({ monthsBack: 12 }), ]); return (

Analytics globaux

Vue d'ensemble plateforme : utilisateurs, activité 30 derniers jours, top performers.

Utilisateurs par rôle

{kpis.usersTotal === 0 ? (

Aucun utilisateur.

) : (
    {Object.entries(kpis.usersByRole) .sort((a, b) => b[1] - a[1]) .map(([role, count]) => { const pct = Math.round((count / kpis.usersTotal) * 100); return (
  • {ROLE_LABEL[role] ?? role} {count} ({pct}%)
  • ); })}
)}

Activité 30 derniers jours

  • Bookings carbet {kpis.bookings30d}
  • Locations matériel {kpis.rentals30d}
  • Total CA 30j {fmtEur(kpis.revenue30d)}

Chiffre d'affaires mensuel

Top carbets (30j)

{kpis.topCarbets.length === 0 ? (

Aucune réservation sur les 30 derniers jours.

) : (
    {kpis.topCarbets.map((c, i) => (
  • #{i + 1} {c.title} {fmtEur(c.revenue)}
  • ))}
)}

Top prestataires rental (30j)

{kpis.topProviders.length === 0 ? (

Aucune location sur les 30 derniers jours.

) : (
    {kpis.topProviders.map((p, i) => (
  • #{i + 1} {p.name} {fmtEur(p.revenue)}
  • ))}
)}
); } function KpiCard({ label, value }: { label: string; value: string | number }) { return (
{label}
{value}
); }