import { ColumnDef } from '@tanstack/react-table'; import { Badge } from '@/components/ui/badge'; import { Activity } from '@/types'; export function getColumns(): ColumnDef[] { return [ { accessorKey: 'date', header: 'Waktu', cell: ({ row }) => (
{row.original.date} {row.original.created_at}
) }, { accessorKey: 'description', header: 'Aksi', cell: ({ row }) => { const label = row.original.description; if (label === 'TAMBAH') { return ( {label} ); } if (label === 'UBAH') { return ( {label} ); } if (label === 'HAPUS') { return ( {label} ); } return ( {label} ); } }, { accessorKey: 'module', header: 'Modul', }, { accessorKey: 'causer', header: 'Oleh', }, { accessorKey: 'properties', header: 'Detail Perubahan', cell: ({ row }) => { const attributes = row.original.properties?.attributes; const old = row.original.properties?.old; if (!attributes) return -; return (
{Object.entries(attributes).map(([key, value]) => { return (
{key}: {old && old[key] !== undefined && String(old[key]) !== String(value) && ( {String(old[key])} )} {old && old[key] !== undefined && String(old[key]) !== String(value) && } {String(value)}
); })}
); } }, ]; }