import { type ColumnDef } from "@tanstack/react-table"; import { Badge } from "@/components/ui/badge"; import type { Audits } from "@/types/audit"; export const auditColumns: ColumnDef[] = [ { header: "Thời gian", accessorKey: "dateTime", cell: ({ getValue }) => { const v = getValue() as string; const d = v ? new Date(v) : null; return d ? (
{d.toLocaleDateString("vi-VN")}
{d.toLocaleTimeString("vi-VN")}
) : ( ); }, }, { header: "User", accessorKey: "username", cell: ({ getValue }) => ( {getValue() as string} ), }, { header: "Loại", accessorKey: "apiCall", cell: ({ getValue }) => { const v = (getValue() as string) ?? ""; if (!v) return ; return ( {v} ); }, }, { header: "Hành động", accessorKey: "action", cell: ({ getValue }) => ( {getValue() as string} ), }, { header: "URL", accessorKey: "url", cell: ({ getValue }) => ( {(getValue() as string) ?? "—"} ), }, { header: "Kết quả", accessorKey: "isSuccess", cell: ({ getValue }) => { const v = getValue(); if (v == null) return ; return v ? ( Thành công ) : ( Thất bại ); }, }, { header: "Nội dung request", accessorKey: "requestPayload", cell: ({ getValue }) => { const v = getValue() as string; if (!v) return ; let preview = v; try { preview = JSON.stringify(JSON.parse(v)); } catch {} return ( {preview} ); }, }, ];