import { useMemo} from "react"; import type { BaseRecord } from "@refinedev/core"; import { useTable } from "@refinedev/react-table"; import { type ColumnDef, flexRender, } from "@tanstack/react-table"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "./ui/table" import { Skeleton } from "./ui/skeleton"; import { DataTablePagination } from "./table-pagination" interface DataTableProps { columns: ColumnDef[] } export function DataTable({ columns, }: DataTableProps) { const table = useTable({ columns, refineCoreProps: { resource: "file" } }) const loadingRows = useMemo(() => Array(4).fill({}).map(() => ({ getIsSelected: () => false, getVisibleCells: () => columns.map(() => ({ column: { columnDef: { cell: , } }, getContext: () => null })), })), []) const rows = table.refineCore.tableQueryResult.isLoading ? loadingRows : table.getRowModel().rows return ( <> {table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => { return ( {header.isPlaceholder ? null : flexRender( header.column.columnDef.header, header.getContext() )} ) })} ))} {rows.length ? ( rows.map((row) => ( {row.getVisibleCells().map((cell) => ( {flexRender(cell.column.columnDef.cell, cell.getContext())} ))} )) ) : ( No results. )}
) }