import { useState } 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 { DataTablePagination } from "./table-pagination" interface DataTableProps { columns: ColumnDef[] } export function DataTable({ columns }: DataTableProps) { const [hoveredRowId, setHoveredRowId] = useState(""); const table = useTable({ columns, meta: { hoveredRowId, }, refineCoreProps: { resource: "files" } }) return (
{table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => { return ( {header.isPlaceholder ? null : flexRender( header.column.columnDef.header, header.getContext() )} ) })} ))} {table.getRowModel().rows?.length ? ( table.getRowModel().rows.map((row) => ( { console.log(hoveredRowId, row.id); setHoveredRowId(row.id) }} > {row.getVisibleCells().map((cell) => ( {flexRender(cell.column.columnDef.cell, cell.getContext())} ))} )) ) : ( No results. )}
) }