import { ColumnDef } from "@tanstack/react-table"; import { Eye, MoreVertical, SendHorizontal, SquarePen, Trash2 } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Checkbox } from "@/components/ui/checkbox"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Badge } from "@/components/ui/badge"; import { cn } from "@/lib/utils"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Link } from '@/i18n/routing'; export type DataProps = { id: string | number; order: number; customer: { name: string; image: string; }; date: string; quantity: number; amount: string; status: "paid" | "due" | "canceled"; action: React.ReactNode; }; export const columns: ColumnDef[] = [ { id: "select", header: ({ table }) => ( table.toggleAllPageRowsSelected(!!value)} aria-label="Select all" className="bg-default-100" /> ), cell: ({ row }) => (
row.toggleSelected(!!value)} aria-label="Select row" className="bg-default-100" />
), enableSorting: false, enableHiding: false, }, { accessorKey: "id", header: "id", cell: ({ row }) => {row.getValue("id")}, }, { accessorKey: "order", header: "Order", cell: ({ row }) => {row.getValue("order")}, }, { accessorKey: "customer", header: "Customer", cell: ({ row }) => { const user = row.original.customer; return (
{user?.image ? ( ) : ( AB )} {user?.name ?? "Unknown User"}
); }, }, { accessorKey: "date", header: "Date", cell: ({ row }) => { return {row.getValue("date")}; }, }, { accessorKey: "quantity", header: "Quantity", cell: ({ row }) => { return {row.getValue("quantity")}; }, }, { accessorKey: "amount", header: "Amount", cell: ({ row }) => { return {row.getValue("amount")}; }, }, { accessorKey: "status", header: "Status", cell: ({ row }) => { const statusColors: Record = { paid: "bg-success/20 text-success", due: "bg-warning/20 text-warning", canceled: "bg-destructive/20 text-destructive", }; const status = row.getValue("status"); const statusStyles = statusColors[status] || "default"; return ( {status}{" "} ); }, }, { id: "actions", accessorKey: "action", header: "Actions", enableHiding: false, cell: ({ row }) => { return (
Sent View Edit Delete
); }, }, ];