'use client' import type { Row } from '@tanstack/react-table' import { useRowActivation } from '@admin/hooks/use-row-activation' import { cn } from '@admin/utils/shared/cn' import { flexRender } from '@tanstack/react-table' import { Fragment } from 'react' interface DataGridListRowProps { row: Row groupColumnId?: string onActivate?: () => void } function DataGridListRow({ row, groupColumnId, onActivate }: DataGridListRowProps) { const { handleClick, handleKeyDown } = useRowActivation({ onActivate }) const [titleCell, ...restCells] = row.getVisibleCells() const actionsCell = restCells.find((cell) => cell.column.id === 'actions') const detailCells = restCells.filter( (cell) => cell.column.id !== 'actions' && cell.column.id !== groupColumnId && cell.column.columnDef.meta?.mobile !== 'hidden' ) return (
{titleCell ? (
{flexRender(titleCell.column.columnDef.cell, titleCell.getContext())}
) : null} {detailCells.length ? (
{detailCells.map((cell, index) => { const meta = cell.column.columnDef.meta return ( {index > 0 ? : null} {meta?.mobile === 'labelled' && meta.label ? {meta.label} : null} {flexRender(cell.column.columnDef.cell, cell.getContext())} ) })}
) : null}
{actionsCell ? (
{flexRender(actionsCell.column.columnDef.cell, actionsCell.getContext())}
) : null}
) } export { DataGridListRow }