import { flexRender, getCoreRowModel, useReactTable, type ColumnDef, } from "@tanstack/react-table"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "../ui/table"; // Define the type for your ingestion log export type IngestionLog = { id: string; createdAt: string; // Add other fields as needed }; const useIngestionLogsColumns = (): ColumnDef[] => [ { accessorKey: "id", header: "ID", cell: (info) => info.getValue(), }, { accessorKey: "createdAt", header: "Created At", cell: (info) => new Date(info.getValue() as string).toLocaleString(), }, { accessorKey: "status", header: "Status", cell: (info) => info.getValue(), }, // Add more columns as needed ]; export const IngestionLogsTable = ({ ingestionLogs, }: { ingestionLogs: IngestionLog[]; }) => { const columns = useIngestionLogsColumns(); const table = useReactTable({ data: ingestionLogs, columns, getCoreRowModel: getCoreRowModel(), }); return (
{table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => ( {header.isPlaceholder ? null : flexRender( header.column.columnDef.header, header.getContext(), )} ))} ))} {table.getRowModel().rows?.length ? ( table.getRowModel().rows.map((row) => ( {row.getVisibleCells().map((cell) => ( {flexRender(cell.column.columnDef.cell, cell.getContext())} ))} )) ) : ( No logs found. )}
); };