import { useEffect, useState } from "react" import { Link } from "react-router-dom" import { Users, UserX, UserCheck, TrendingUp, ArrowRight, List, UsersRound, } from "lucide-react" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "../../components/ui/card" import { SpinnerIcon } from "../../components/ui/spinner-icon" import { getDashboard } from "../../api/analytics.api" import type { DashboardUsers } from "../../types/analytics.types" export function UserManagementDashboard() { const [stats, setStats] = useState(null) const [statsLoading, setStatsLoading] = useState(true) useEffect(() => { const fetchStats = async () => { try { const res = await getDashboard() const usersData = (res.data as any)?.users ?? (res.data as any)?.data?.users ?? null setStats(usersData) } catch { // silently fail — cards will show "—" } finally { setStatsLoading(false) } } fetchStats() }, []) const formatNum = (n: number) => n.toLocaleString() const activeUsers = stats?.by_status?.find((item) => item.label?.toUpperCase() === "ACTIVE")?.count ?? null return (
{/* Page Header */}

User Management

Manage users, groups, and registrations.

{/* Stat Cards */}

Total Users

{statsLoading ? : stats ? formatNum(stats.total_users) : "—"}

Active Users

{statsLoading ? ( ) : activeUsers !== null ? ( formatNum(activeUsers) ) : ( "—" )}

New This Month

{statsLoading ? ( ) : stats ? ( formatNum(stats.new_month) ) : ( "—" )}

{/* Action Cards */}

Quick Actions

Deletion Requests Review account deletion requests and user deletion states.
View requests
User Groups Manage groups, roles, and permission settings.
Manage groups
User List Browse, search, and manage all registered users.
View all users
) }