import { prisma } from "@/lib/prisma"; import { Users, BarChart3, Wallet, Clock, ArrowUpRight, } 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 AdminDashboard() { const [pendingReimbursements, pendingOvertime, totalBudget, recentTransactions] = await Promise.all([ prisma.reimbursement.count({ where: { status: 'PENDING' } }), prisma.overtime.count({ where: { status: 'PENDING' } }), prisma.budget.aggregate({ _sum: { amount: true } }), prisma.companyTransaction.findMany({ orderBy: { date: 'desc' }, take: 5 }) ]); const totalPending = pendingReimbursements + pendingOvertime; return (

Admin Console

Real-time overview of company finances and worker requests.

{[ { label: 'Total Budget Allocated', value: formatCurrency(totalBudget._sum.amount?.toString() || '0'), icon: Wallet, color: 'emerald', trend: '+5.2% vs last month' }, { label: 'Pending Approvals', value: totalPending.toString(), icon: Clock, color: 'amber', trend: `${pendingReimbursements} claims, ${pendingOvertime} OT` }, { label: 'Monthly Revenue', value: formatCurrency(245000), icon: BarChart3, color: 'indigo', trend: 'On track for Q1' }, { label: 'Active Personnel', value: '142', icon: Users, color: 'violet', trend: '+3 new this week' }, ].map((stat, i) => (

{stat.label}

{stat.value}

{stat.trend}

))}

Financial Ledger

{(recentTransactions as any[]).map((tx) => (
{tx.type === 'DEBIT' ? '-' : '+'}

{tx.description}

{new Date(tx.date).toLocaleDateString()}

{tx.type === 'DEBIT' ? '-' : '+'}{formatCurrency(tx.amount.toString())}

Success
))}

Budget Health

Total budget utilization is at 68%. Marketing and Sales are nearing their monthly limits.

Departmental Spend

{[ { label: 'Marketing', value: 85, color: 'bg-emerald-500' }, { label: 'Engineering', value: 62, color: 'bg-indigo-500' }, { label: 'Operations', value: 48, color: 'bg-violet-500' }, ].map((item) => (
{item.label} 80 ? 'text-rose-500' : ''}>{item.value}%
))}
); }