mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 13:35:24 +02:00
Implement Excel-style stock filtering with Smart Filters and Range support
This commit is contained in:
@@ -62,6 +62,7 @@ const App: React.FC = () => {
|
||||
asin: [],
|
||||
sku: [],
|
||||
title: [],
|
||||
stock: [],
|
||||
});
|
||||
|
||||
// Handle Data Fetch (Simplified)
|
||||
@@ -386,8 +387,8 @@ const App: React.FC = () => {
|
||||
return metaMap;
|
||||
}, [rawData]);
|
||||
|
||||
const filteredData = useMemo(() => filterData(rawData, filters), [rawData, filters]);
|
||||
const filteredAdsData = useMemo(() => filterAdsData(adsData, filters, globalAsinMetadata), [adsData, filters, globalAsinMetadata]);
|
||||
const filteredData = useMemo(() => filterData(rawData, filters, stockMap), [rawData, filters, stockMap]);
|
||||
const filteredAdsData = useMemo(() => filterAdsData(adsData, filters, globalAsinMetadata, stockMap), [adsData, filters, globalAsinMetadata, stockMap]);
|
||||
const aggregatedData = useMemo(() => aggregateData(filteredData), [filteredData]);
|
||||
|
||||
// Calculate country-aware Top 50 Best Sellers for 2025
|
||||
@@ -445,7 +446,8 @@ const App: React.FC = () => {
|
||||
line: activeLines, // Force these lines
|
||||
sku: [], // Clear specific item filters
|
||||
asin: [],
|
||||
title: []
|
||||
title: [],
|
||||
stock: []
|
||||
};
|
||||
|
||||
// 3. Process this broader dataset
|
||||
@@ -466,8 +468,14 @@ const App: React.FC = () => {
|
||||
sku: getUniqueValues(rawData, 'sku'),
|
||||
title: getUniqueValues(rawData, 'title'),
|
||||
week: Array.from(new Set(rawData.map(r => r.week).filter(w => w !== undefined))).sort((a, b) => (a as number) - (b as number)).map(w => `W${w}`),
|
||||
stock: [
|
||||
'Out of Stock (0)',
|
||||
'In Stock (>0)',
|
||||
'Low Stock (<10)',
|
||||
...Array.from(new Set(Array.from(stockMap.values()).map(String))).sort((a, b) => parseFloat(a) - parseFloat(b))
|
||||
]
|
||||
};
|
||||
}, [rawData]);
|
||||
}, [rawData, stockMap]);
|
||||
|
||||
const handleFilterChange = (key: keyof FilterState, value: string[]) => {
|
||||
setFilters(prev => ({ ...prev, [key]: value }));
|
||||
|
||||
Reference in New Issue
Block a user