74bc3073a7
- add optional `permission` field to `registerWidget` api - filter widgets in `DashboardPage` based on user permissions - register users widget with `users.view` permission requirement - document `permission` parameter in admin README
24 lines
730 B
JavaScript
24 lines
730 B
JavaScript
'use client';
|
|
|
|
import { registerWidget } from '../registry.js';
|
|
import { StatCard } from '@zen/core/shared/components';
|
|
import { UserMultiple02Icon } from '@zen/core/shared/icons';
|
|
|
|
function UsersWidget({ data, loading }) {
|
|
const newThisMonth = data?.newThisMonth ?? 0;
|
|
return (
|
|
<StatCard
|
|
title="Nombre d'utilisateurs"
|
|
value={loading ? '-' : String(data?.totalUsers ?? 0)}
|
|
change={!loading && newThisMonth > 0 ? `+${newThisMonth} ce mois` : undefined}
|
|
changeType="increase"
|
|
icon={UserMultiple02Icon}
|
|
color="text-blue-700"
|
|
bgColor="bg-blue-700/10"
|
|
loading={loading}
|
|
/>
|
|
);
|
|
}
|
|
|
|
registerWidget({ id: 'users', Component: UsersWidget, order: 10, permission: 'users.view' });
|