'use client'; import { flexRender } from '@tanstack/react-table'; import { TableHead, TableHeader as ShadTableHeader, TableRow } from '@/components/ui/table'; import { Table } from '@tanstack/react-table'; import { ArrowDownWideNarrow, ArrowUpDown, ArrowUpNarrowWide } from 'lucide-react'; import { cn } from '@/lib/utils'; const TableHeader = ({ table }: { table: Table }) => { return ( {table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => { const canSort = header.column.getCanSort(); const sortDirection = header.column.getIsSorted(); const SortIcon = sortDirection === 'asc' ? ArrowUpNarrowWide : sortDirection === 'desc' ? ArrowDownWideNarrow : ArrowUpDown; return ( {header.isPlaceholder ? null : (
{flexRender(header.column.columnDef.header, header.getContext())} {canSort ? ( ) : null}
)}
); })}
))}
); }; export default TableHeader;