From 9c078464fb1ea6345afa2f76c7b9ab0cf0d3de6f Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 16 Dec 2025 05:50:48 +0000 Subject: [PATCH] restructured measures button --- .../reporting/ReportingClientArea.tsx | 71 +++++++++++++++++-- 1 file changed, 64 insertions(+), 7 deletions(-) diff --git a/src/app/portfolio/[slug]/(portfolio)/reporting/ReportingClientArea.tsx b/src/app/portfolio/[slug]/(portfolio)/reporting/ReportingClientArea.tsx index 9c1782d..6d71f37 100644 --- a/src/app/portfolio/[slug]/(portfolio)/reporting/ReportingClientArea.tsx +++ b/src/app/portfolio/[slug]/(portfolio)/reporting/ReportingClientArea.tsx @@ -7,6 +7,7 @@ import { DashboardSummaryCards } from "./DashboardSummaryCards"; import { BreakdownChart } from "./BreakdownChart"; import { EpcQualityCards } from "./EpcQualityCards"; import { ScenarioFinancialDrawer } from "./ScenarioFinancialDrawer"; +import { ScenarioMeasuresModal } from "./ScenarioMeasuresModal"; import { SectionDivider } from "@/app/portfolio/[slug]/(portfolio)/reporting/SectionDivider"; import { @@ -48,6 +49,24 @@ async function fetchScenarioReport({ return res.json(); } +async function fetchScenarioMeasures({ + portfolioId, + scenarioId, +}: { + portfolioId: number; + scenarioId: number; +}) { + const res = await fetch( + `/api/portfolio/${portfolioId}/scenario/${scenarioId}/measures` + ); + + if (!res.ok) { + throw new Error("Failed to load measures"); + } + + return res.json(); +} + export function ReportingClientArea({ baseline, propertyTypes, @@ -57,6 +76,7 @@ export function ReportingClientArea({ const [selectedScenarioId, setSelectedScenarioId] = useState( null ); + const [measuresOpen, setMeasuresOpen] = useState(false); const drawerOpen = Boolean(selectedScenarioId); @@ -77,6 +97,22 @@ export function ReportingClientArea({ enabled: !!selectedScenarioId, // only run when scenario selected }); + const { + data: measuresData, + isLoading: measuresLoading, + isError: measuresError, + } = useQuery({ + queryKey: ["scenario-measures", portfolioId, selectedScenarioId], + queryFn: () => + fetchScenarioMeasures({ + portfolioId, + scenarioId: selectedScenarioId!, + }), + enabled: measuresOpen && !!selectedScenarioId, + }); + + const scenarioLoading = isLoading && !!selectedScenarioId; + // ---------------------------------------- // Build overlay for Dashboard Summary cards // ---------------------------------------- @@ -158,13 +194,18 @@ export function ReportingClientArea({ {selectedScenarioId && (
@@ -239,6 +288,14 @@ export function ReportingClientArea({ subtitle="Total bills, cost exposure, and potential funding pathways." /> + + setMeasuresOpen(false)} + isLoading={measuresLoading} + data={measuresData ?? null} + error={measuresError} + /> ); }