import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'; import { Head, Link } from '@inertiajs/react'; import React from 'react'; import { PageProps } from '@/types'; import { Chart as ChartJS, CategoryScale, LinearScale, PointElement, LineElement, BarElement, Title, Tooltip, Legend, Filler, ArcElement, } from 'chart.js'; import { Line, Bar, Doughnut } from 'react-chartjs-2'; ChartJS.register( CategoryScale, LinearScale, PointElement, LineElement, BarElement, ArcElement, Title, Tooltip, Legend, Filler ); interface RecentUser { id: number; first_name: string; last_name: string; email: string; status: string; avatar_url?: string; created_at: string; roles: { name: string }[]; } interface ChartItem { label: string; value: number; } interface DashboardStats { totalUsers: number; activeUsers: number; totalRoles: number; recentUsers: RecentUser[]; charts: { userGrowth: ChartItem[]; activityStats: ChartItem[]; }; } interface DashboardProps extends PageProps { stats: DashboardStats; } function StatCard({ label, value, sub, icon, variant = 'white', delay = '0s' }: { label: string; value: string | number; sub: string; icon: React.ReactNode; variant?: 'white' | 'dark' | 'gold' | 'teal'; delay?: string; }) { const styles = { white: 'bg-white text-[#3D4E4B] border border-gray-100', dark: 'bg-[#3D4E4B] text-white border border-[#3D4E4B]', gold: 'bg-[#D4A017] text-white border border-[#D4A017]', teal: 'bg-[#21A59F] text-white border border-[#21A59F]', }; return (

{label}

{typeof value === 'number' ? value.toLocaleString() : value}

{icon}

{sub}

); } export default function Dashboard({ stats }: DashboardProps) { const { totalUsers, activeUsers, totalRoles, recentUsers, charts } = stats; const inactiveUsers = totalUsers - activeUsers; // User Growth Chart Configuration const growthData = { labels: charts.userGrowth.map(d => d.label), datasets: [ { label: 'New Registrations', data: charts.userGrowth.map(d => d.value), borderColor: '#D4A017', backgroundColor: 'rgba(212, 160, 23, 0.1)', fill: true, tension: 0.4, pointRadius: 4, pointBackgroundColor: '#D4A017', }, ], }; // Activity Bar Chart Configuration const activityData = { labels: charts.activityStats.map(d => d.label), datasets: [ { label: 'System Activity', data: charts.activityStats.map(d => d.value), backgroundColor: '#3D4E4B', borderRadius: 8, }, ], }; const chartOptions = { responsive: true, maintainAspectRatio: false, plugins: { legend: { display: false }, tooltip: { backgroundColor: '#3D4E4B', titleFont: { size: 12, weight: 'bold' as const }, padding: 12, cornerRadius: 12, }, }, scales: { x: { grid: { display: false }, ticks: { font: { size: 10, weight: 'bold' as const }, color: '#9ca3af' } }, y: { border: { display: false }, ticks: { font: { size: 10, weight: 'bold' as const }, color: '#9ca3af' }, grid: { color: '#f3f4f6' } }, }, }; return (
{/* Stats row */}
} /> 0 ? Math.round((activeUsers / totalUsers) * 100) : 0}% of total`} variant="dark" delay="0.08s" icon={} /> } /> } />
{/* Growth Chart */}

User Growth

Registration metrics over the last 6 months

Accounts
{/* Breakdown Chart */}

Account Integrity

Global Status Registry

Verified Active
{activeUsers}
Restricted/Inactive
{inactiveUsers}
{/* Activity Logs Bar Chart */}

System Pulse

{/* Recent Users Table */}

Recent Registry

View Full Archive →
{recentUsers.map(u => { const initials = `${u.first_name?.charAt(0) ?? ''}${u.last_name?.charAt(0) ?? ''}`.toUpperCase(); return (
{u.avatar_url ? : initials}

{u.first_name} {u.last_name}

{u.email}

{u.status}
); })}
); }