import { ColumnDef, flexRender, getCoreRowModel, useReactTable, getPaginationRowModel, } from "@tanstack/react-table"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { Button } from "@/components/ui/button"; import { useState } from "react"; interface DataTableProps { columns: ColumnDef[]; data: TData[]; //style: any; } export function NotifyTable({ columns, data, //style, }: DataTableProps) { const [pagination, setPagination] = useState({ pageIndex: 0, //initial page index pageSize: 5, //default page size }); const table = useReactTable({ data, columns, getCoreRowModel: getCoreRowModel(), getPaginationRowModel: getPaginationRowModel(), onPaginationChange: setPagination, state: { //... pagination, }, }); // console.log(parseInt(style.height.replace("px", "")) - 50); 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) => ( {row.getVisibleCells().map((cell) => ( {flexRender( cell.column.columnDef.cell, cell.getContext() )} ))} )) ) : ( No results. )}
); }