Add admin hooks, components, and tests for statistics, navigation, and access control
- Introduced `useAdminStats`, `useAdminUsers`, and `useAdminOrganizations` hooks for admin data fetching with React Query. - Added `AdminSidebar`, `Breadcrumbs`, and related navigation components for the admin section. - Implemented comprehensive unit and integration tests for admin components. - Created E2E tests for admin access control, navigation, and dashboard functionality. - Updated exports to include new admin components.
This commit is contained in:
63
frontend/src/components/admin/DashboardStats.tsx
Normal file
63
frontend/src/components/admin/DashboardStats.tsx
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* DashboardStats Component
|
||||
* Displays admin dashboard statistics in stat cards
|
||||
*/
|
||||
|
||||
'use client';
|
||||
|
||||
import { useAdminStats } from '@/lib/api/hooks/useAdmin';
|
||||
import { StatCard } from './StatCard';
|
||||
import { Users, UserCheck, Building2, Activity } from 'lucide-react';
|
||||
import { Alert, AlertDescription } from '@/components/ui/alert';
|
||||
import { AlertCircle } from 'lucide-react';
|
||||
|
||||
export function DashboardStats() {
|
||||
const { data: stats, isLoading, isError, error } = useAdminStats();
|
||||
|
||||
if (isError) {
|
||||
return (
|
||||
<Alert variant="destructive">
|
||||
<AlertCircle className="h-4 w-4" />
|
||||
<AlertDescription>
|
||||
Failed to load dashboard statistics: {error?.message || 'Unknown error'}
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className="grid gap-4 md:grid-cols-2 lg:grid-cols-4"
|
||||
data-testid="dashboard-stats"
|
||||
>
|
||||
<StatCard
|
||||
title="Total Users"
|
||||
value={stats?.totalUsers ?? 0}
|
||||
icon={Users}
|
||||
description="All registered users"
|
||||
loading={isLoading}
|
||||
/>
|
||||
<StatCard
|
||||
title="Active Users"
|
||||
value={stats?.activeUsers ?? 0}
|
||||
icon={UserCheck}
|
||||
description="Users with active status"
|
||||
loading={isLoading}
|
||||
/>
|
||||
<StatCard
|
||||
title="Organizations"
|
||||
value={stats?.totalOrganizations ?? 0}
|
||||
icon={Building2}
|
||||
description="Total organizations"
|
||||
loading={isLoading}
|
||||
/>
|
||||
<StatCard
|
||||
title="Active Sessions"
|
||||
value={stats?.totalSessions ?? 0}
|
||||
icon={Activity}
|
||||
description="Current active sessions"
|
||||
loading={isLoading}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user