import type { ReactNode } from 'react'; import { EmptyState } from './ui/EmptyState'; export type TableColumn = { key: string; label: string; render: (item: TItem) => ReactNode; }; type DataTableProps = { items: TItem[]; columns: TableColumn[]; getRowKey: (item: TItem) => string; actions?: (item: TItem) => ReactNode; emptyTitle?: string; emptyDescription?: string; }; export function DataTable({ items, columns, getRowKey, actions, emptyTitle, emptyDescription, }: DataTableProps) { return (
{columns.map((column) => ( ))} {actions && } {items.length === 0 ? ( ) : ( items.map((item) => ( {columns.map((column) => ( ))} {actions && } )) )}
{column.label} Действия
{column.render(item)} {actions(item)}
); }