import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table'; import { flexRender, type Row, type Table as TableType, } from '@tanstack/react-table'; import { type ReactNode } from 'react'; /** * The bordered table the settings pages list their records in. Deliberately not * the virtualized DataTable: these lists are short, and each page renders its * own row component (they carry a per-row context menu). */ export function SettingsTable({ table, emptyMessage, renderRow, }: { table: TableType; emptyMessage: string; renderRow: (row: Row) => ReactNode; }) { const rows = table.getRowModel().rows; return ( // Scrolls rather than clips: the accounts table is wider than a phone.
{table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => ( {header.isPlaceholder ? null : flexRender( header.column.columnDef.header, header.getContext(), )} ))} ))} {rows.length ? ( rows.map(renderRow) ) : ( {emptyMessage} )}
); }