"use client" import * as React from "react" import { ColumnDef, flexRender, getCoreRowModel, useReactTable, getPaginationRowModel, SortingState, getSortedRowModel, getFilteredRowModel, RowSelectionState, } from "@tanstack/react-table" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/shared/components/ui/table" import { Button } from "@/shared/components/ui/button" import { ChevronLeft, ChevronRight } from "lucide-react" interface DataTableProps { columns: ColumnDef[] data: TData[] } export function ExamDataTable({ columns, data }: DataTableProps) { const [sorting, setSorting] = React.useState([]) const [rowSelection, setRowSelection] = React.useState({}) const table = useReactTable({ data, columns, getCoreRowModel: getCoreRowModel(), getPaginationRowModel: getPaginationRowModel(), onSortingChange: setSorting, getSortedRowModel: getSortedRowModel(), onRowSelectionChange: setRowSelection, getFilteredRowModel: getFilteredRowModel(), state: { sorting, rowSelection, }, }) 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. )}
{table.getFilteredSelectedRowModel().rows.length} of {table.getFilteredRowModel().rows.length} row(s) selected.

Page

{table.getState().pagination.pageIndex + 1} of {table.getPageCount()}
) }