diff --git a/src/app/components/building-passport/RecommendationCard.tsx b/src/app/components/building-passport/RecommendationCard.tsx index 94876f3..65018c5 100644 --- a/src/app/components/building-passport/RecommendationCard.tsx +++ b/src/app/components/building-passport/RecommendationCard.tsx @@ -27,7 +27,11 @@ export const uvalueColumns: ColumnDef[] = [ cell: ({ row }) => ( row.toggleSelected(!!value)} + onCheckedChange={(value) => { + if (value === true && !row.getIsSelected()) { + row.toggleSelected(true); + } + }} aria-label="Select row" /> ), diff --git a/src/app/components/building-passport/RecommendationTable.tsx b/src/app/components/building-passport/RecommendationTable.tsx index 6c0c050..fc5d9cc 100644 --- a/src/app/components/building-passport/RecommendationTable.tsx +++ b/src/app/components/building-passport/RecommendationTable.tsx @@ -17,10 +17,20 @@ import { } from "@/app/shadcn_components/ui/table"; import { ComponentRecommendation } from "@/app/db/schema/recommendations"; +import { Dispatch, SetStateAction } from "react"; interface DataTableProps { columns: ColumnDef[]; data: T[]; + defaultRowIndex: number; + rowSelection: { + [x: number]: boolean; + }; + setRowSelection: Dispatch< + SetStateAction<{ + [x: number]: boolean; + }> + >; } export default function RecommendationTable({ @@ -37,6 +47,17 @@ export default function RecommendationTable({ columns, getCoreRowModel: getCoreRowModel(), onRowSelectionChange: setRowSelection, + // onRowSelectionChange: (RowSelectionState) => { + // // This is a hack but we cast RowSelectionState's type into a function so we can avoid typescript errors + // // but this allows us the functionality we need to prevent de-selecting already selected rows + // const RowSelectionStateCallable = RowSelectionState as Function; + // const rowSelection = Object(RowSelectionStateCallable()); + + // if (Object.keys(rowSelection).length !== 0) { + // console.log("in here?"); + // setRowSelection(rowSelection); + // } + // }, enableMultiRowSelection: false, enableSubRowSelection: false, state: {