import { auth } from "@/auth"; import { prisma } from "@/lib/prisma"; import { DollarSign, Receipt, Clock, Wallet, ArrowUpRight, TrendingUp, CreditCard, Zap } from "lucide-react"; import { Card } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { formatCurrency } from "@/lib/utils"; import Link from "next/link"; export default async function WorkerDashboard() { const session = await auth(); const userId = (session?.user as any)?.id; const [reimbursements, overtimes] = await Promise.all([ prisma.reimbursement.findMany({ where: { userId }, orderBy: { createdAt: 'desc' }, take: 5 }), prisma.overtime.findMany({ where: { userId }, take: 20 }) ]); const pendingClaimsCount = await prisma.reimbursement.count({ where: { userId, status: 'PENDING' } }); const totalSpendingAgg = await prisma.reimbursement.aggregate({ where: { userId, status: 'PAID' }, _sum: { amount: true } }); const overtimeHours = overtimes.reduce((acc, curr) => acc + curr.hours, 0); return (

Welcome back, {(session?.user?.name || 'User').split(' ')[0]}

Your financial activity and pending requests at a glance.

{[ { label: 'Total Spending', value: formatCurrency(totalSpendingAgg._sum.amount?.toString() || '0'), icon: DollarSign, color: 'indigo', trend: '+12% this month' }, { label: 'Pending Claims', value: pendingClaimsCount.toString(), icon: Receipt, color: 'amber', trend: 'Wait time: ~2 days' }, { label: 'Overtime Hours', value: `${overtimeHours}h`, icon: Clock, color: 'violet', trend: 'YTD tracking' }, { label: 'Next Payout', value: formatCurrency(2450), icon: Wallet, color: 'emerald', trend: 'Due in 12 days' }, ].map((stat, i) => (

{stat.label}

{stat.value}

{stat.trend}

))}

Recent Activity

{reimbursements.map((item) => (

{item.description}

{item.category} {new Date(item.createdAt).toLocaleDateString()}

{formatCurrency(item.amount.toString())}

{item.status}
))}

Quick Wallet Tip

You have {pendingClaimsCount} pending reimbursement requests. Claims are usually processed within 48 hours.

Spending Snapshot

{[ { label: 'Travel', value: 45, color: 'bg-indigo-500' }, { label: 'Dining', value: 30, color: 'bg-emerald-500' }, { label: 'Supplies', value: 25, color: 'bg-amber-500' }, ].map((item) => (
{item.label} {item.value}%
))}
); }