"use client" import { ColumnDef, flexRender, getCoreRowModel, useReactTable } from "@tanstack/react-table"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; interface DataTableProps { columns: ColumnDef[]; data: TData[]; onRowClick?: (row: TData) => void; } export function DataTable({ columns, data, onRowClick }: DataTableProps) { const table = useReactTable({ data, columns, getCoreRowModel: getCoreRowModel(), }); return (
{table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => ( {header.isPlaceholder ? null : flexRender( header.column.columnDef.header, header.getContext() )} ))} ))} {table.getRowCount() === 0 &&
There are no pending applications
} {table.getRowModel().rows.map((row) => ( onRowClick?.(row.original)}> {row.getVisibleCells().map((cell) => ( {flexRender(cell.column.columnDef.cell, cell.getContext())} ))} ))}
) }