From d1a522a4464fcc7cd0c192a20e4ca7a481576488 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Wed, 28 Jan 2026 13:05:08 +0100 Subject: [PATCH] Update ForecastView with v2.2 version tag and ensure correct import --- components/ForecastView.tsx | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/components/ForecastView.tsx b/components/ForecastView.tsx index fbf2858..f11abec 100644 --- a/components/ForecastView.tsx +++ b/components/ForecastView.tsx @@ -119,10 +119,10 @@ const ForecastRow: React.FC<{
- {fcAchievement.toFixed(1)}% + {ytdAchievement.toFixed(1)}%
- OF ANNUAL {Math.round(annualForecast / 1000)}K + OF PERIOD {Math.round(forecastPeriod / 1000)}K
@@ -164,10 +164,21 @@ const ForecastView: React.FC = ({ const [displayCount, setDisplayCount] = useState(50); const lastDataMonthIdx = useMemo(() => { + // Find the last month with actual data + let maxDataMonth = 0; for (let i = MONTH_ORDER.length - 1; i >= 0; i--) { - if (data.some(p => (p.monthlyData?.[MONTH_ORDER[i]]?.actualUnits || 0) > 0)) return i; + if (data.some(p => (p.monthlyData?.[MONTH_ORDER[i]]?.actualUnits || 0) > 0)) { + maxDataMonth = i; + break; + } } - return 0; + + // Clamp to current month to ensure we don't show future months in "Period" view + // This fixes the issue where "Period" shows Annual forecast if there is any stray future data + const currentMonth = new Date().getMonth(); // 0 for Jan + // We assume the data is for the current year if we are in FC 26 view. + // If we want to support past years, we'd need to check the year context, but for now this fixes the user's immediate issue. + return Math.min(maxDataMonth, currentMonth); }, [data]); const activeMonths = useMemo(() => { @@ -321,7 +332,9 @@ const ForecastView: React.FC = ({ {/* Bottom Section: Table */}
-

Product Performance Comparison

+

+ Product Performance Comparison (v2.2 Updated) +

{top50Ranking && (top50Ranking.eu.size > 0 || top50Ranking.uk.size > 0) && (