import React from "react"; import clsx from "clsx"; import { ColumnDef, Table, flexRender } from "@tanstack/react-table"; import { Activity } from "src/interfaces/activity"; import { ChevronDownIcon } from "./icons/chevron-down"; type Props = { table: Table; columns: ColumnDef[]; selected: string | null; onSelect: (identifier: string | null) => void; }; export const MonitorTable = ({ table, columns, selected, onSelect }: Props) => { return ( <>
{table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => ( ))} ))} {table.getRowModel().rows.map((row) => { const isSelected = row.original.identifier === selected; return ( { onSelect( selected === row.original.identifier ? null : row.original.identifier, ); }} > {row.getVisibleCells().map((cell) => ( ))} ); })}
{flexRender( header.column.columnDef.header, header.getContext(), )} {{ asc: ( ), desc: ( ), }[ header.column.getIsSorted() as string ] ?? null}
{flexRender( cell.column.columnDef.cell, cell.getContext(), )}
{`${ table.getState().pagination.pageIndex + 1 } of ${table.getPageCount()}`}
); };