import { prisma } from '@/lib/prisma' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Building2, MessageSquare, CheckCircle, XCircle, Clock } from 'lucide-react' export default async function DashboardPage() { const [totalClients, activeClients, pendingCount, sentCount, failedCount] = await Promise.all([ prisma.client.count(), prisma.client.count({ where: { isActive: true } }), prisma.smsQueue.count({ where: { status: { in: ['PENDING', 'RETRYING'] } } }), prisma.smsQueue.count({ where: { status: 'SENT' } }), prisma.smsQueue.count({ where: { status: 'FAILED' } }), ]) const recentLogs = await prisma.smsLog.findMany({ take: 10, orderBy: { sentAt: 'desc' }, include: { client: { select: { name: true } }, queue: true }, }) const stats = [ { title: 'Total Clients', value: totalClients, sub: `${activeClients} active`, icon: Building2, color: 'text-blue-600' }, { title: 'Pending SMS', value: pendingCount, sub: 'In queue', icon: Clock, color: 'text-yellow-600' }, { title: 'SMS Sent', value: sentCount, sub: 'All time', icon: CheckCircle, color: 'text-green-600' }, { title: 'Failed SMS', value: failedCount, sub: 'Needs attention', icon: XCircle, color: 'text-red-600' }, ] return (

Dashboard

Overview of your NFC Attendance Hub

{stats.map(stat => { const Icon = stat.icon return ( {stat.title}
{stat.value}

{stat.sub}

) })}
Recent SMS Activity {recentLogs.length === 0 ? (

No SMS activity yet

) : (
{recentLogs.map(log => (
{log.queue.studentName} ({log.queue.studentId}) via {log.client.name}
{log.queue.event === 'time_in' ? '✅ Time In' : '🔴 Time Out'} {log.status}
))}
)}
) }