diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index 4222666..cf98a62 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -1,6 +1,118 @@ -import { redirect } from "next/navigation"; +import { getDashboardStats } from "@/lib/dashboard-queries"; +import { Users, FolderOpen, Euro, Clock } from "lucide-react"; -// Dashboard page — content added in Phase 6 Plan 02 -export default function AdminRoot() { - redirect("/admin/clients"); +export const revalidate = 0; + +function KpiCard({ + label, + value, + sub, + icon: Icon, + color, +}: { + label: string; + value: string | number; + sub?: string; + icon: React.ElementType; + color: string; +}) { + return ( +
+
+ +
+
+

{label}

+

{value}

+ {sub &&

{sub}

} +
+
+ ); +} + +const ACTIVITY_ICONS: Record = { + nuovo_cliente: "👤", + nuovo_progetto: "📁", + deliverable_approvato: "✅", + timer_stoppato: "⏱", +}; + +function fmt(ts: Date) { + return new Intl.DateTimeFormat("it-IT", { + day: "2-digit", + month: "short", + hour: "2-digit", + minute: "2-digit", + }).format(new Date(ts)); +} + +function fmtEur(val: string) { + return new Intl.NumberFormat("it-IT", { style: "currency", currency: "EUR" }).format( + parseFloat(val) || 0 + ); +} + +export default async function AdminDashboard() { + const { kpi, activity } = await getDashboardStats(); + + return ( +
+

Dashboard

+ + {/* KPI cards */} +
+ + + + +
+ + {/* Activity feed */} +
+
+

Attività recente

+
+ {activity.length === 0 ? ( +

Nessuna attività recente

+ ) : ( +
    + {activity.map((item, i) => ( +
  • +
    + {ACTIVITY_ICONS[item.type]} +
    +

    {item.label}

    +

    {item.detail}

    +
    +
    + {fmt(item.timestamp)} +
  • + ))} +
+ )} +
+
+ ); }