import { FullPageEmptyState } from '@/components/full-page-empty-state'; import { FloatingPagination } from '@/components/pagination-floating'; import { Skeleton } from '@/components/skeleton'; import { cn } from '@/utils/cn'; import type { Table as ITable } from '@tanstack/react-table'; import { flexRender } from '@tanstack/react-table'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '../table'; import { getCommonPinningStyles } from './data-table-helpers'; export interface DataTableProps { table: ITable; className?: string; loading?: boolean; empty?: { title: string; description: string; }; } declare module '@tanstack/react-table' { interface ColumnMeta { pinned?: 'left' | 'right'; bold?: boolean; } } export function DataTable({ table, loading, className, empty = { title: 'No data', description: 'We could not find any data here yet', }, ...props }: DataTableProps) { return (
{table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => ( {header.isPlaceholder ? null : flexRender( header.column.columnDef.header, header.getContext(), )} ))} ))} {table.getRowModel().rows?.length ? ( table.getRowModel().rows.map((row) => ( {row.getVisibleCells().map((cell) => ( {loading ? ( ) : ( flexRender( cell.column.columnDef.cell, cell.getContext(), ) )} ))} )) ) : ( )}
{table.getPageCount() > 1 && ( <>
)}
); }