feat(admin): add core users widget and reorganize dashboard widget registration

This commit is contained in:
2026-04-22 13:27:04 -04:00
parent 692f639cb5
commit 12f66a2115
10 changed files with 90 additions and 63 deletions
-22
View File
@@ -1,22 +0,0 @@
/**
* Auth Feature — Contribution serveur au tableau de bord
*
* Ce module s'auto-enregistre auprès du registre admin en side effect.
* Dépendance correcte : auth → admin (feature → core).
*/
import { registerServerWidget } from '../admin/dashboard/registry.js';
import { query } from '@zen/core/database';
import { fail } from '@zen/core/shared/logger';
async function getDashboardData() {
try {
const result = await query(`SELECT COUNT(*) as count FROM zen_auth_users`);
return { totalUsers: parseInt(result.rows[0].count) || 0 };
} catch (error) {
fail(`Auth dashboard data error: ${error.message}`);
return { totalUsers: 0 };
}
}
registerServerWidget('auth', getDashboardData);
-33
View File
@@ -1,33 +0,0 @@
'use client';
/**
* Auth Feature — Widget client pour le tableau de bord
*
* Ce module s'auto-enregistre auprès du registre admin en side effect.
* Dépendance correcte : auth → admin (feature → core).
*
* Props du composant :
* data — { totalUsers: number } retourné par getDashboardData(), ou null
* loading — true tant que les données serveur ne sont pas disponibles
*/
import { registerClientWidget } from '../admin/dashboard/clientRegistry.js';
import { StatCard } from '@zen/core/shared/components';
import { UserMultiple02Icon } from '@zen/core/shared/icons';
function AuthDashboardWidget({ data, loading }) {
return (
<StatCard
title="Nombre d'utilisateurs"
value={loading ? '-' : String(data?.totalUsers ?? 0)}
icon={UserMultiple02Icon}
color="text-purple-400"
bgColor="bg-purple-500/10"
loading={loading}
/>
);
}
registerClientWidget('auth', AuthDashboardWidget, 10);
export default AuthDashboardWidget;