"use client" import { ColumnDef, } from "@tanstack/react-table" import { Eye, MoreVertical, SquarePen, Trash2 } from "lucide-react" import { Button } from "@/components/ui/button" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import { cn } from "@/lib/utils" export type DataProps = { id: string | number; customer: { name: string; image: string; }; history: { transId: string; }, date: string; amount: string; status?: "paid" | "due" | "cancel"; action: React.ReactNode; } export const columns: ColumnDef[] = [ { accessorKey: "customer", header: "Customer", cell: ({ row }) => { const user = row.original.customer; return (
{user?.image ? ( ) : ( AB )} {user?.name ?? "Unknown User"}
) } }, { accessorKey: "history", header: "History", cell: ({ row }) => { return (
Transfer
Trans ID: {row.original.history.transId}
) } }, { accessorKey: "date", header: "Date", cell: ({ row }) => { return ( {row.getValue("date")} ) } }, { accessorKey: 'status', header: 'Amount', cell: ({ row }) => { const status = (row.getValue('status') || 'paid') as 'paid' | 'due' | 'cancel'; const classes: { [key in 'paid' | 'due' | 'cancel']: string } = { paid: 'text-primary', due: 'text-warning', cancel: 'text-destructive', }; return {row.original.amount}; } }, { id: "actions", accessorKey: "action", header: "Actions", enableHiding: false, cell: ({ row }) => { return (
View Edit Delete
) } } ]