mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 12:45: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
|
||||
|
||||
// Combine Sales & Ads Data dynamically based on current filters
|
||||
const combinedAdsData = useMemo(() => {
|
||||
return mergeSalesAndAdsData(filteredData, filteredAdsData, globalAsinMetadata, trafficData, velocityMap);
|
||||
}, [filteredData, filteredAdsData, globalAsinMetadata, trafficData, velocityMap]);
|
||||
}, [filteredData, filteredAdsData, globalAsinMetadata, trafficData, velocityMap]);
|
||||
|
||||
// Derived Data for Grid (YTD Filtered - Isolated)
|
||||
// 1. Identify "Current Year" max week
|
||||
const gridContext = useMemo(() => {
|
||||
// Derived Data for Grid (YTD Filtered - Isolated)
|
||||
// 1. Identify "Current Year" max week
|
||||
const gridContext = useMemo(() => {
|
||||
if (rawData.length === 0) return { minWeek: 1, maxWeek: 53, currentYear: new Date().getFullYear() };
|
||||
|
||||
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));
|
||||
|
||||
return { minWeek: 1, maxWeek: maxWeek || 53, currentYear };
|
||||
}, [rawData]);
|
||||
}, [rawData]);
|
||||
|
||||
const ytdGridData = useMemo(() => {
|
||||
const ytdGridData = useMemo(() => {
|
||||
// Filter combinedAdsData to only include weeks <= maxWeek
|
||||
// This ensures we compare "Like for Like" periods across years
|
||||
// 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)
|
||||
return item.week <= gridContext.maxWeek;
|
||||
});
|
||||
}, [combinedAdsData, gridContext.maxWeek]);
|
||||
}, [combinedAdsData, gridContext.maxWeek]);
|
||||
|
||||
// Derived Data for Views
|
||||
const years = useMemo(() => getUniqueValues(rawData, 'year').sort().reverse(), [rawData]);
|
||||
// Derived Data for Views
|
||||
const years = useMemo(() => getUniqueValues(rawData, 'year').sort().reverse(), [rawData]);
|
||||
|
||||
// Derive Context Data (Product Line Context when drilling down)
|
||||
const contextAggregatedData = useMemo(() => {
|
||||
// Derive Context Data (Product Line Context when drilling down)
|
||||
const contextAggregatedData = useMemo(() => {
|
||||
// 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;
|
||||
|
||||
@@ -553,11 +554,11 @@ const contextAggregatedData = useMemo(() => {
|
||||
const broadData = filterData(rawData, contextFilters);
|
||||
return aggregateData(broadData);
|
||||
|
||||
}, [rawData, filters, filteredData]);
|
||||
}, [rawData, filters, filteredData]);
|
||||
|
||||
|
||||
// Derive Options for Filter Dropdowns
|
||||
const filterOptions = useMemo(() => {
|
||||
// Derive Options for Filter Dropdowns
|
||||
const filterOptions = useMemo(() => {
|
||||
return {
|
||||
customer: getUniqueValues(rawData, 'customer'),
|
||||
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))
|
||||
]
|
||||
};
|
||||
}, [rawData, stockMap]);
|
||||
}, [rawData, stockMap]);
|
||||
|
||||
const handleFilterChange = (key: keyof FilterState, value: string[]) => {
|
||||
const handleFilterChange = (key: keyof FilterState, value: string[]) => {
|
||||
setFilters(prev => ({ ...prev, [key]: value }));
|
||||
};
|
||||
};
|
||||
|
||||
const handleAskGemini = async (text: string) => {
|
||||
const handleAskGemini = async (text: string) => {
|
||||
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
|
||||
localStorage.removeItem('craze_csv_url');
|
||||
await clearSalesData();
|
||||
@@ -592,9 +593,9 @@ const disconnectUrl = async () => {
|
||||
setActiveUrl(null);
|
||||
setRawData([]);
|
||||
setAdsData([]);
|
||||
};
|
||||
};
|
||||
|
||||
return (
|
||||
return (
|
||||
<div className="min-h-screen flex flex-col bg-background text-slate-200">
|
||||
|
||||
{/* Header */}
|
||||
@@ -825,7 +826,7 @@ return (
|
||||
}
|
||||
|
||||
</div >
|
||||
);
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
||||
|
||||
Reference in New Issue
Block a user