import { ArchiveX } from 'lucide-react'; import * as React from 'react'; import { BaseEntity } from '@/types/api'; import { cn } from '@/utils/cn'; const TableElement = React.forwardRef< HTMLTableElement, React.HTMLAttributes >(({ className, ...props }, ref) => (
)); TableElement.displayName = 'Table'; const TableHeader = React.forwardRef< HTMLTableSectionElement, React.HTMLAttributes >(({ className, ...props }, ref) => ( )); TableHeader.displayName = 'TableHeader'; const TableBody = React.forwardRef< HTMLTableSectionElement, React.HTMLAttributes >(({ className, ...props }, ref) => ( )); TableBody.displayName = 'TableBody'; const TableFooter = React.forwardRef< HTMLTableSectionElement, React.HTMLAttributes >(({ className, ...props }, ref) => ( tr]:last:border-b-0', className, )} {...props} /> )); TableFooter.displayName = 'TableFooter'; const TableRow = React.forwardRef< HTMLTableRowElement, React.HTMLAttributes >(({ className, ...props }, ref) => ( )); TableRow.displayName = 'TableRow'; const TableHead = React.forwardRef< HTMLTableCellElement, React.ThHTMLAttributes >(({ className, ...props }, ref) => (
[role=checkbox]]:translate-y-[2px]', className, )} {...props} /> )); TableHead.displayName = 'TableHead'; const TableCell = React.forwardRef< HTMLTableCellElement, React.TdHTMLAttributes >(({ className, ...props }, ref) => ( [role=checkbox]]:translate-y-[2px]', className, )} {...props} /> )); TableCell.displayName = 'TableCell'; const TableCaption = React.forwardRef< HTMLTableCaptionElement, React.HTMLAttributes >(({ className, ...props }, ref) => (
)); TableCaption.displayName = 'TableCaption'; export { TableElement, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, }; type TableColumn = { title: string; field: keyof Entry; Cell?({ entry }: { entry: Entry }): React.ReactElement; }; export type TableProps = { data: Entry[]; columns: TableColumn[]; }; export const Table = ({ data, columns, }: TableProps) => { if (!data?.length) { return (

No Entries Found

); } return ( {columns.map((column, index) => ( {column.title} ))} {data.map((entry, entryIndex) => ( {columns.map(({ Cell, field, title }, columnIndex) => ( {Cell ? : `${entry[field]}`} ))} ))} ); };