diff --git a/packages/web/app/scenarios/[id]/page.tsx b/packages/web/app/scenarios/[id]/page.tsx index d95ec8d..1ca2012 100644 --- a/packages/web/app/scenarios/[id]/page.tsx +++ b/packages/web/app/scenarios/[id]/page.tsx @@ -224,32 +224,33 @@ export default function ScenarioPage() { ) : (
{hasResults ? ( - { - try { - const inputs = scenario?.inputs_json ? JSON.parse(scenario.inputs_json) : {}; - return inputs?.project?.cod_year || inputs?.project?.cod_date - ? new Date(inputs.project.cod_date || inputs.project.cod_year + '-04-01').getFullYear() - : new Date().getFullYear(); - } catch { return new Date().getFullYear(); } - })()} - solarDCMW={(() => { - try { - const inputs = scenario?.inputs_json ? JSON.parse(scenario.inputs_json) : {}; - return inputs?.solar?.capacity_dc_mwp || inputs?.project?.capacity_solar_mwp || 0; - } catch { return 0; } - })()} - windMW={(() => { - try { - const inputs = scenario?.inputs_json ? JSON.parse(scenario.inputs_json) : {}; - return inputs?.wind?.capacity_mw || inputs?.project?.capacity_wind_mw || 0; - } catch { return 0; } - })()} - /> + { + try { + const inputs = scenario?.inputs_json ? JSON.parse(scenario.inputs_json) : {}; + return inputs?.project?.cod_year || inputs?.project?.cod_date + ? new Date(inputs.project.cod_date || inputs.project.cod_year + '-04-01').getFullYear() + : new Date().getFullYear(); + } catch { return new Date().getFullYear(); } + })()} + solarDCMW={(() => { + try { + const inputs = scenario?.inputs_json ? JSON.parse(scenario.inputs_json) : {}; + return inputs?.solar?.capacity_dc_mwp || inputs?.project?.capacity_solar_mwp || 0; + } catch { return 0; } + })()} + windMW={(() => { + try { + const inputs = scenario?.inputs_json ? JSON.parse(scenario.inputs_json) : {}; + return inputs?.wind?.capacity_mw || inputs?.project?.capacity_wind_mw || 0; + } catch { return 0; } + })()} + onNavigate={(sheet) => setActiveSheet(sheet as ActiveSheet)} + /> ) : scenario?.status === "failed" ? (

Scenario failed

diff --git a/packages/web/components/KpiCard.tsx b/packages/web/components/KpiCard.tsx index a797197..133eb38 100644 --- a/packages/web/components/KpiCard.tsx +++ b/packages/web/components/KpiCard.tsx @@ -3,12 +3,14 @@ interface KpiCardProps { value: string | null; unit?: string; highlight?: boolean; + onClick?: () => void; } -export function KpiCard({ label, value, unit, highlight }: KpiCardProps) { +export function KpiCard({ label, value, unit, highlight, onClick }: KpiCardProps) { return (
{label} diff --git a/packages/web/components/WorkbookView.tsx b/packages/web/components/WorkbookView.tsx index 10f237d..7ec58f3 100644 --- a/packages/web/components/WorkbookView.tsx +++ b/packages/web/components/WorkbookView.tsx @@ -298,7 +298,7 @@ function buildDebtRows(debt: DebtYearRow[]): TableRow[] { // Sheet views // --------------------------------------------------------------------------- -function SummarySheet({ kpis, scenarioId }: { kpis: KpiSummary; scenarioId: string }) { +function SummarySheet({ kpis, scenarioId, onNavigate }: { kpis: KpiSummary; scenarioId: string; onNavigate?: (sheet: string) => void }) { const { data: stmts } = useQuery({ queryKey: ["statements", scenarioId], queryFn: () => getStatements(scenarioId), @@ -364,25 +364,72 @@ function SummarySheet({ kpis, scenarioId }: { kpis: KpiSummary; scenarioId: stri value={kpis.solved_tariff_inr_per_kwh != null ? kpis.solved_tariff_inr_per_kwh.toFixed(2) : null} unit="₹/kWh" highlight + onClick={() => onNavigate?.("generation")} /> onNavigate?.("irr")} + /> + onNavigate?.("irr")} + /> + onNavigate?.("debt")} + /> + onNavigate?.("debt")} + /> + onNavigate?.("debt")} + /> + onNavigate?.("debt")} + /> + onNavigate?.("idc")} + /> + onNavigate?.("irr")} + /> + onNavigate?.("irr")} /> - - - - - - - - {kpis.solar_y1_cuf != null && ( - + onNavigate?.("generation")} + /> )} {kpis.wind_y1_plf != null && ( - + onNavigate?.("generation")} + /> )} {kpis.rtc_cuf_achieved != null && ( @@ -997,9 +1044,10 @@ interface Props { codYear?: number; solarDCMW?: number; windMW?: number; + onNavigate?: (sheet: string) => void; } -export function WorkbookView({ scenarioId, kpis, debtScheduleJson, activeSheet, codYear, solarDCMW, windMW }: Props) { +export function WorkbookView({ scenarioId, kpis, debtScheduleJson, activeSheet, codYear, solarDCMW, windMW, onNavigate }: Props) { const { data: stmts } = useQuery({ queryKey: ["statements", scenarioId], queryFn: () => getStatements(scenarioId), @@ -1032,7 +1080,7 @@ export function WorkbookView({ scenarioId, kpis, debtScheduleJson, activeSheet, All monetary values in INR Crore unless noted

- {activeSheet === "summary" && } + {activeSheet === "summary" && } {activeSheet === "pnl" && pnl.length > 0 && ( )}