From d5a76d5b976e68b5a0e3f7b6014326050d3ed601 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Wed, 28 Jan 2026 12:39:37 +0100 Subject: [PATCH] Fix syntax error in ForecastView iteration logic --- components/ForecastView.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/components/ForecastView.tsx b/components/ForecastView.tsx index bffa74a..61a545b 100644 --- a/components/ForecastView.tsx +++ b/components/ForecastView.tsx @@ -159,7 +159,7 @@ const ForecastView: React.FC = ({ const lastDataMonthIdx = useMemo(() => { for (let i = MONTH_ORDER.length - 1; i >= 0; i--) { - if (data.some(p => p.monthlyData[MONTH_ORDER[i]]?.units > 0)) return i; + if (data.some(p => (p.monthlyData?.[MONTH_ORDER[i]]?.actualUnits || 0) > 0)) return i; } return 0; }, [data]); @@ -192,13 +192,15 @@ const ForecastView: React.FC = ({ MONTH_ORDER.forEach(m => dataMap.set(m, { name: m, actual: 0, forecast: 0 })); baseFilteredData.forEach(item => { - item.monthlyData?.forEach(m => { - const entry = dataMap.get(m.month); - if (entry) { - entry.actual += m.actual || 0; - entry.forecast += m.forecast || 0; - } - }); + if (item.monthlyData) { + Object.values(item.monthlyData).forEach((m: any) => { + const entry = dataMap.get(m.month); + if (entry) { + entry.actual += m.actualUnits || 0; + entry.forecast += m.forecastUnits || 0; + } + }); + } }); return Array.from(dataMap.values()); }, [baseFilteredData]);