64 lines
1.5 KiB
TypeScript
64 lines
1.5 KiB
TypeScript
import { m } from '@paraglide/messages';
|
|
import { ColumnDef } from '@tanstack/react-table';
|
|
import { Badge } from '@ui/badge';
|
|
import { formatters } from '@utils/formatters';
|
|
|
|
import { LOG_ACTION } from '@/types/enum';
|
|
import ActionBadge from './action-badge';
|
|
import ViewDetailAudit from './view-log-detail-dialog';
|
|
|
|
export const logColumns: ColumnDef<AuditWithUser>[] = [
|
|
{
|
|
accessorFn: (row) => row.user?.name ?? '',
|
|
header: m.logs_page_ui_table_header_username(),
|
|
meta: {
|
|
thClass: 'w-1/6',
|
|
},
|
|
},
|
|
{
|
|
accessorKey: 'tableName',
|
|
header: m.logs_page_ui_table_header_table(),
|
|
meta: {
|
|
thClass: 'w-1/6',
|
|
},
|
|
cell: ({ row }) => {
|
|
return (
|
|
<Badge variant="table" className="px-3 py-1 text-xs">
|
|
{row.original.tableName}
|
|
</Badge>
|
|
);
|
|
},
|
|
},
|
|
{
|
|
accessorKey: 'action',
|
|
header: m.logs_page_ui_table_header_action(),
|
|
meta: {
|
|
thClass: 'w-1/6',
|
|
},
|
|
cell: ({ row }) => {
|
|
return <ActionBadge action={row.original.action as LOG_ACTION} />;
|
|
},
|
|
},
|
|
{
|
|
accessorKey: 'createdAt',
|
|
header: m.logs_page_ui_table_header_create_at(),
|
|
meta: {
|
|
thClass: 'w-2/6',
|
|
},
|
|
cell: ({ row }) => {
|
|
return formatters.dateTime(new Date(row.original.createdAt));
|
|
},
|
|
},
|
|
{
|
|
id: 'actions',
|
|
meta: {
|
|
thClass: 'w-1/6',
|
|
},
|
|
cell: ({ row }) => (
|
|
<div className="flex justify-end">
|
|
<ViewDetailAudit data={row.original} />
|
|
</div>
|
|
),
|
|
},
|
|
];
|