import { Checkbox } from "@/src/components/ui/checkbox"; import { type Table, type Row, type RowSelectionState, } from "@tanstack/react-table"; import { useSelectAll } from "@/src/features/table/hooks/useSelectAll"; interface TableSelectionManagerProps { projectId: string; tableName: string; setSelectedRows: (rows: RowSelectionState) => void; } export function TableSelectionManager({ projectId, tableName, setSelectedRows, }: TableSelectionManagerProps) { const { setSelectAll } = useSelectAll(projectId, tableName); return { selectActionColumn: { id: "select", accessorKey: "select", size: 35, isFixedPosition: true, isPinnedLeft: true, header: ({ table }: { table: Table }) => (
{ table.toggleAllPageRowsSelected(!!value); if (!value) { setSelectedRows({}); setSelectAll(false); } }} aria-label="Select all" className="opacity-60" />
), cell: ({ row }: { row: Row }) => (
{ e.stopPropagation(); }} > { row.toggleSelected(!!value); if (!value) setSelectAll(false); }} aria-label="Select row" className="opacity-60" />
), }, }; }