import { ExpandListButton } from "@/src/features/dashboard/components/cards/ChevronButton"; import { useState, type ReactNode } from "react"; import { NoDataOrLoading } from "@/src/components/NoDataOrLoading"; type TableHeaders = ReactNode[]; type TableRows = ReactNode[][]; type DashboardTableProps = { headers: TableHeaders; rows: TableRows; children?: ReactNode; collapse?: { collapsed: number; expanded: number; }; noDataProps?: { description: string; href: string; }; isLoading: boolean; }; export const DashboardTable = ({ headers, rows, children, collapse, noDataProps, isLoading, }: DashboardTableProps) => { const [isExpanded, setExpanded] = useState(false); return ( <> {children} {rows.length > 0 ? (
{headers.map((header, i) => ( ))} {rows .slice( 0, collapse ? isExpanded ? collapse.expanded : collapse.collapsed : undefined, ) .map((row, i) => ( {row.map((cell, j) => ( ))} ))}
{header}
{cell}
{collapse ? ( collapse.expanded ? `Show top ${collapse.expanded}` : "Show all" } /> ) : null}
) : ( )} ); };