'use client' import type { TableRowGroup } from '@admin/utils/table/group-table-rows' import type { Row } from '@tanstack/react-table' import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@admin/components/ui/collapsible' import { cn } from '@admin/utils/shared/cn' import { ChevronDown, ChevronUp } from 'lucide-react' import { useState } from 'react' import { DataGridListRow } from './data-grid-list-row' const GROUP_PREVIEW_ROWS = 4 interface DataGridGroupProps { group: TableRowGroup groupColumnId?: string onActivateRow?: (row: Row) => void } function DataGridGroup({ group, groupColumnId, onActivateRow }: DataGridGroupProps) { const [open, setOpen] = useState(true) const [showAll, setShowAll] = useState(false) const visibleRows = showAll ? group.rows : group.rows.slice(0, GROUP_PREVIEW_ROWS) const hiddenCount = group.rows.length - visibleRows.length return ( {group.indicator ? ( {visibleRows.map((row) => ( onActivateRow(row) : undefined} /> ))} {hiddenCount > 0 ? ( ) : null} ) } export { DataGridGroup }