"use client"; import { LeaveRequest, daysBetween } from "@/lib/leavesStore"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { Button } from "@/components/ui/button"; import { CheckCircle2, XCircle, Clock, CalendarRange } from "lucide-react"; interface LeaveTableProps { leaves: LeaveRequest[]; isManager?: boolean; onApprove?: (id: number) => void; onReject?: (id: number) => void; loadingId?: number | null; } const STATUS_CONFIG = { Approved: { className: "status-approved", icon: CheckCircle2, }, Pending: { className: "status-pending", icon: Clock, }, Rejected: { className: "status-rejected", icon: XCircle, }, }; const formatDate = (dateString: string) => { const date = new Date(dateString); const day = date.getDate(); const month = date.toLocaleString("en-US", { month: "short" }); const year = date.getFullYear(); return `${day} ${month}, ${year}`; }; export function LeaveTable({ leaves, isManager, onApprove, onReject, loadingId }: LeaveTableProps) { if (leaves.length === 0) { return (
No leave requests yet
{isManager ? "No requests to review" : "Apply for your first leave"}