diff --git a/src/app/components/building-passport/RecommendationCard.tsx b/src/app/components/building-passport/RecommendationCard.tsx index 60e865d..94876f3 100644 --- a/src/app/components/building-passport/RecommendationCard.tsx +++ b/src/app/components/building-passport/RecommendationCard.tsx @@ -23,13 +23,7 @@ export const uvalueColumns: ColumnDef[] = [ { accessorKey: "default", id: "default", - header: ({ table }) => ( - table.toggleAllPageRowsSelected(!!value)} - aria-label="Select all" - /> - ), + header: "Selected?", cell: ({ row }) => ( ("None"); const [buttonDisabled, setButtonDisabled] = useState(true); + // Find the row where default is true + const defaultRowIndex = recommendationData.findIndex((d) => d.default); + + // Initialise the state with the default row index + const [rowSelection, setRowSelection] = useState( + defaultRowIndex !== -1 ? { [defaultRowIndex]: true } : {} + ); + function closeModal() { setIsOpen(false); + // If the user closes the modal, re-set the state of the row selection to the default, since nothing has changed + setRowSelection({ [defaultRowIndex]: true }); } function handlePortfolioNameChange(e: React.ChangeEvent) { @@ -108,13 +112,16 @@ export function RecommendationModal({