import type { ColumnDef } from '@tanstack/react-table'; import { Eye } from 'lucide-react'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; export type FormHistory = { id: number; causer_id: number; module: string; event: string; description: string; attribute_changes: { new?: Record; old?: Record; } | null; created_at: string; formatted_created_at: string; causer: { id: number; username: string; full_name: string; }; }; const eventBadgeVariant: Record = { created: 'default', updated: 'secondary', deleted: 'destructive', }; const eventLabel: Record = { created: 'Ditambahkan', updated: 'Diperbarui', deleted: 'Dihapus', }; type CreateColumnsParams = { handleDetail: (item: FormHistory) => void; }; export function createFormHistoryColumns({ handleDetail }: CreateColumnsParams): ColumnDef[] { return [ { accessorKey: 'formatted_created_at', header: () => Waktu, cell: ({ row }) => ( {row.original.formatted_created_at} ), }, { accessorKey: 'causer', header: () => User, cell: ({ row }) => ( {row.original.causer?.full_name ?? row.original.causer?.username ?? '-'} ), }, { accessorKey: 'module', header: () => Module, cell: ({ row }) => ( {row.getValue('module') as string} ), }, { accessorKey: 'event', header: () => Aksi, cell: ({ row }) => { const event = row.getValue('event') as string; return ( {eventLabel[event] ?? event} ); }, }, { accessorKey: 'description', header: () => Deskripsi, cell: ({ row }) => ( {row.getValue('description') as string} ), }, { id: 'actions', header: () => Aksi, meta: { className: 'w-[80px] text-center', headerClassName: 'w-[80px] text-center', }, cell: ({ row }) => ( ), }, ]; }