mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 22:15:23 +02:00
Fix syntax error in App.tsx: Restore missing useMemo declaration
This commit is contained in:
@@ -497,12 +497,13 @@ const App: React.FC = () => {
|
|||||||
// Determine which dataset to use for velocity calculation based on top50Mode
|
// Determine which dataset to use for velocity calculation based on top50Mode
|
||||||
|
|
||||||
// Combine Sales & Ads Data dynamically based on current filters
|
// Combine Sales & Ads Data dynamically based on current filters
|
||||||
|
const combinedAdsData = useMemo(() => {
|
||||||
return mergeSalesAndAdsData(filteredData, filteredAdsData, globalAsinMetadata, trafficData, velocityMap);
|
return mergeSalesAndAdsData(filteredData, filteredAdsData, globalAsinMetadata, trafficData, velocityMap);
|
||||||
}, [filteredData, filteredAdsData, globalAsinMetadata, trafficData, velocityMap]);
|
}, [filteredData, filteredAdsData, globalAsinMetadata, trafficData, velocityMap]);
|
||||||
|
|
||||||
// Derived Data for Grid (YTD Filtered - Isolated)
|
// Derived Data for Grid (YTD Filtered - Isolated)
|
||||||
// 1. Identify "Current Year" max week
|
// 1. Identify "Current Year" max week
|
||||||
const gridContext = useMemo(() => {
|
const gridContext = useMemo(() => {
|
||||||
if (rawData.length === 0) return { minWeek: 1, maxWeek: 53, currentYear: new Date().getFullYear() };
|
if (rawData.length === 0) return { minWeek: 1, maxWeek: 53, currentYear: new Date().getFullYear() };
|
||||||
|
|
||||||
const currentYear = Math.max(...rawData.map(r => r.year));
|
const currentYear = Math.max(...rawData.map(r => r.year));
|
||||||
@@ -510,9 +511,9 @@ const gridContext = useMemo(() => {
|
|||||||
const maxWeek = Math.max(...currentYearData.map(r => r.week).filter(Boolean));
|
const maxWeek = Math.max(...currentYearData.map(r => r.week).filter(Boolean));
|
||||||
|
|
||||||
return { minWeek: 1, maxWeek: maxWeek || 53, currentYear };
|
return { minWeek: 1, maxWeek: maxWeek || 53, currentYear };
|
||||||
}, [rawData]);
|
}, [rawData]);
|
||||||
|
|
||||||
const ytdGridData = useMemo(() => {
|
const ytdGridData = useMemo(() => {
|
||||||
// Filter combinedAdsData to only include weeks <= maxWeek
|
// Filter combinedAdsData to only include weeks <= maxWeek
|
||||||
// This ensures we compare "Like for Like" periods across years
|
// This ensures we compare "Like for Like" periods across years
|
||||||
// We do strictly LESS THAN OR EQUAL to maxWeek.
|
// We do strictly LESS THAN OR EQUAL to maxWeek.
|
||||||
@@ -522,13 +523,13 @@ const ytdGridData = useMemo(() => {
|
|||||||
if (!item.week) return true; // Keep non-weekly items if any (shouldn't be)
|
if (!item.week) return true; // Keep non-weekly items if any (shouldn't be)
|
||||||
return item.week <= gridContext.maxWeek;
|
return item.week <= gridContext.maxWeek;
|
||||||
});
|
});
|
||||||
}, [combinedAdsData, gridContext.maxWeek]);
|
}, [combinedAdsData, gridContext.maxWeek]);
|
||||||
|
|
||||||
// Derived Data for Views
|
// Derived Data for Views
|
||||||
const years = useMemo(() => getUniqueValues(rawData, 'year').sort().reverse(), [rawData]);
|
const years = useMemo(() => getUniqueValues(rawData, 'year').sort().reverse(), [rawData]);
|
||||||
|
|
||||||
// Derive Context Data (Product Line Context when drilling down)
|
// Derive Context Data (Product Line Context when drilling down)
|
||||||
const contextAggregatedData = useMemo(() => {
|
const contextAggregatedData = useMemo(() => {
|
||||||
// Check if we are filtering by specific items (SKU, ASIN, Title)
|
// Check if we are filtering by specific items (SKU, ASIN, Title)
|
||||||
const hasItemFilters = filters.sku.length > 0 || filters.asin.length > 0 || filters.title.length > 0;
|
const hasItemFilters = filters.sku.length > 0 || filters.asin.length > 0 || filters.title.length > 0;
|
||||||
|
|
||||||
@@ -553,11 +554,11 @@ const contextAggregatedData = useMemo(() => {
|
|||||||
const broadData = filterData(rawData, contextFilters);
|
const broadData = filterData(rawData, contextFilters);
|
||||||
return aggregateData(broadData);
|
return aggregateData(broadData);
|
||||||
|
|
||||||
}, [rawData, filters, filteredData]);
|
}, [rawData, filters, filteredData]);
|
||||||
|
|
||||||
|
|
||||||
// Derive Options for Filter Dropdowns
|
// Derive Options for Filter Dropdowns
|
||||||
const filterOptions = useMemo(() => {
|
const filterOptions = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
customer: getUniqueValues(rawData, 'customer'),
|
customer: getUniqueValues(rawData, 'customer'),
|
||||||
year: getUniqueValues(rawData, 'year'),
|
year: getUniqueValues(rawData, 'year'),
|
||||||
@@ -574,17 +575,17 @@ const filterOptions = useMemo(() => {
|
|||||||
...Array.from(new Set(Array.from(stockMap.values()).map(String))).sort((a, b) => parseFloat(a) - parseFloat(b))
|
...Array.from(new Set(Array.from(stockMap.values()).map(String))).sort((a, b) => parseFloat(a) - parseFloat(b))
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
}, [rawData, stockMap]);
|
}, [rawData, stockMap]);
|
||||||
|
|
||||||
const handleFilterChange = (key: keyof FilterState, value: string[]) => {
|
const handleFilterChange = (key: keyof FilterState, value: string[]) => {
|
||||||
setFilters(prev => ({ ...prev, [key]: value }));
|
setFilters(prev => ({ ...prev, [key]: value }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAskGemini = async (text: string) => {
|
const handleAskGemini = async (text: string) => {
|
||||||
return await queryGemini(text, aggregatedData, filteredData.length);
|
return await queryGemini(text, aggregatedData, filteredData.length);
|
||||||
};
|
};
|
||||||
|
|
||||||
const disconnectUrl = async () => {
|
const disconnectUrl = async () => {
|
||||||
// Allow disconnecting to clear data, but the app will likely re-connect on next reload due to "Permanent" requirement
|
// Allow disconnecting to clear data, but the app will likely re-connect on next reload due to "Permanent" requirement
|
||||||
localStorage.removeItem('craze_csv_url');
|
localStorage.removeItem('craze_csv_url');
|
||||||
await clearSalesData();
|
await clearSalesData();
|
||||||
@@ -592,9 +593,9 @@ const disconnectUrl = async () => {
|
|||||||
setActiveUrl(null);
|
setActiveUrl(null);
|
||||||
setRawData([]);
|
setRawData([]);
|
||||||
setAdsData([]);
|
setAdsData([]);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen flex flex-col bg-background text-slate-200">
|
<div className="min-h-screen flex flex-col bg-background text-slate-200">
|
||||||
|
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
@@ -825,7 +826,7 @@ return (
|
|||||||
}
|
}
|
||||||
|
|
||||||
</div >
|
</div >
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
|||||||
Reference in New Issue
Block a user