'use client' import type { Row, Table } from '@tanstack/react-table' import { cn } from '@admin/utils/shared/cn' import { groupTableRows } from '@admin/utils/table/group-table-rows' import { DataGridGroup } from './data-grid-group' import { DataGridListRow } from './data-grid-list-row' interface DataGridGroupedListProps { table: Table className?: string onActivateRow?: (row: Row) => void } function DataGridGroupedList({ table, className, onActivateRow }: DataGridGroupedListProps) { const groupColumn = table .getVisibleLeafColumns() .find((column) => column.columnDef.meta?.mobile === 'group') const rows = table.getRowModel().rows if (!groupColumn) { return (
{rows.map((row) => ( onActivateRow(row) : undefined} /> ))}
) } return (
{groupTableRows(rows, groupColumn).map((group) => ( ))}
) } export { DataGridGroupedList }