From 4e8b84bcd3850f79150277b8e371b528f0466ec0 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Tue, 27 Jan 2026 09:37:58 +0100 Subject: [PATCH] Refine Forecast View: Dynamic 'Actual Units Sales' based on customer filters --- App.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/App.tsx b/App.tsx index 7c35423..9df7ea8 100644 --- a/App.tsx +++ b/App.tsx @@ -173,12 +173,17 @@ const App: React.FC = () => { } }, []); - // Update forecast when customer filter changes + // Update forecast when filters change useEffect(() => { if (rawData.length > 0) { - handleForecastFetch(rawData, filters.customer); + // Filter rawData to respect customer selections but keep all years (2025 for seasonality, 2026 for actuals) + const forecastRelevantData = filterData(rawData, { + ...filters, + year: [] // Ensure we don't filter out 2025/2026 if a single year is selected in UI + }); + handleForecastFetch(forecastRelevantData, filters.customer); } - }, [filters.customer, rawData, handleForecastFetch]); + }, [filters, rawData, handleForecastFetch]); const initializeData = (data: SalesRecord[]) => { setRawData(data);