"use client" import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip" import { ColumnDef, } from "@tanstack/react-table" import { Eye, 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"; 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" /> ), cell: ({ row }) => (
row.toggleSelected(!!value)} aria-label="Select row" />
), 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: "Action", enableHiding: false, cell: ({ row }) => { return (

View

Edit

Delete

) } } ]