import { useMemo} from "react"; import { BaseRecord } from "@refinedev/core"; import { useTable } from "@refinedev/react-table"; import { 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: "files" } }) 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. )}
) }