import * as React from 'react'; import { ColumnDef, flexRender, getCoreRowModel, useReactTable, } from '@tanstack/react-table'; import TableHeader from './TableHeader'; import { IconProp } from '@fortawesome/fontawesome-svg-core'; type OwnProps = { data: Array; columns: Array>; viewName: string; viewIcon?: IconProp; }; function Table({ data, columns, viewName, viewIcon }: OwnProps) { const table = useReactTable({ data, columns, getCoreRowModel: getCoreRowModel(), }); return (
{table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => ( ))} ))} {table.getRowModel().rows.map((row) => ( {row.getVisibleCells().map((cell) => ( ))} ))} {table.getFooterGroups().map((footerGroup) => ( {footerGroup.headers.map((header) => ( ))} ))}
{header.isPlaceholder ? null : flexRender( header.column.columnDef.header, header.getContext(), )}
{flexRender(cell.column.columnDef.cell, cell.getContext())}
{header.isPlaceholder ? null : flexRender( header.column.columnDef.footer, header.getContext(), )}
); } export default Table;