mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 12:55:23 +02:00
Fix syntax error in ForecastView iteration logic
This commit is contained in:
@@ -159,7 +159,7 @@ const ForecastView: React.FC<ForecastViewProps> = ({
|
||||
|
||||
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<ForecastViewProps> = ({
|
||||
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]);
|
||||
|
||||
Reference in New Issue
Block a user