refactor(admin): replace static dashboard stats with dynamic widget registry
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
'use client';
|
||||
|
||||
import { StatCard } from '@zen/core/shared/components';
|
||||
import { UserMultiple02Icon } from '@zen/core/shared/icons';
|
||||
import { getClientWidgets } from '../../dashboard/clientRegistry.js';
|
||||
import '../../../dashboard.client.js';
|
||||
|
||||
export default function DashboardPage({ user, stats }) {
|
||||
const loading = !stats;
|
||||
// Évalué après tous les imports : les auto-registrations sont complètes
|
||||
const sortedWidgets = getClientWidgets();
|
||||
|
||||
export default function DashboardPage({ stats }) {
|
||||
const loading = stats === null || stats === undefined;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4 sm:gap-6 lg:gap-8">
|
||||
@@ -18,14 +21,13 @@ export default function DashboardPage({ user, stats }) {
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 sm:gap-6">
|
||||
<StatCard
|
||||
title="Nombre d'utilisateurs"
|
||||
value={loading ? '-' : String(stats?.totalUsers || 0)}
|
||||
icon={UserMultiple02Icon}
|
||||
color="text-purple-400"
|
||||
bgColor="bg-purple-500/10"
|
||||
loading={loading}
|
||||
/>
|
||||
{sortedWidgets.map(({ id, Component }) => (
|
||||
<Component
|
||||
key={id}
|
||||
data={loading ? null : (stats[id] ?? null)}
|
||||
loading={loading}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user