diff --git a/src/components/Table.tsx b/src/components/Table.tsx index cfd77df6..d3498e33 100644 --- a/src/components/Table.tsx +++ b/src/components/Table.tsx @@ -48,6 +48,8 @@ export interface TableProps { sorting?: SortingState; setSorting?: OnChangeFn; manualSorting?: boolean; + rowSelection?: Record; + setRowSelection?: OnChangeFn>; } const DUMMY_SKELETON_DATA = [{}, {}, {}, {}, {}]; @@ -86,6 +88,8 @@ const Table = ({ sorting, setSorting, manualSorting = false, + rowSelection, + setRowSelection, }: TableProps) => { const isServerSideTable = totalItems !== undefined && @@ -137,6 +141,15 @@ const Table = ({ }; } + if (rowSelection && setRowSelection) { + tableOptions.onRowSelectionChange = setRowSelection; + tableOptions.state = { + ...tableOptions.state, + rowSelection, + }; + tableOptions.getRowId = (row) => (row as { id: string }).id; + } + const table = useReactTable(tableOptions); const { setPageSize } = table;