mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 12:15:23 +02:00
feat: implement bulk search for ASINs/SKUs in DataGrid
This commit is contained in:
@@ -843,7 +843,24 @@ export const filterAdsData = (
|
||||
const stockMatch = checkStockFilter(meta?.sku || '', filters.stock, stockMap);
|
||||
const vendorStockMatch = checkVendorStockFilter(asin, filters.vendorStock, vendorStockMap, top50Mode);
|
||||
|
||||
return countryMatch && yearMatch && weekMatch && asinMatch && skuMatch && lineMatch && stockMatch && vendorStockMatch;
|
||||
// Bulk Search Logic
|
||||
let bulkMatch = true;
|
||||
if (filters.bulkSearch && filters.bulkSearch.trim()) {
|
||||
const searchTerms = filters.bulkSearch
|
||||
.split(/[\s,\n]+/)
|
||||
.map(t => t.trim().toUpperCase())
|
||||
.filter(t => t.length > 0);
|
||||
|
||||
if (searchTerms.length > 0) {
|
||||
const itemAsin = (asin || '').toUpperCase();
|
||||
const itemSku = (meta?.sku || '').toUpperCase();
|
||||
bulkMatch = searchTerms.some(term =>
|
||||
itemAsin.includes(term) || itemSku.includes(term)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return countryMatch && yearMatch && weekMatch && asinMatch && skuMatch && lineMatch && stockMatch && vendorStockMatch && bulkMatch;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -873,6 +890,23 @@ export const filterData = (
|
||||
const skuMatch = filters.sku.length === 0 || filters.sku.includes(item.sku);
|
||||
const titleMatch = filters.title.length === 0 || filters.title.includes(item.title);
|
||||
|
||||
// Bulk Search Logic
|
||||
let bulkMatch = true;
|
||||
if (filters.bulkSearch && filters.bulkSearch.trim()) {
|
||||
const searchTerms = filters.bulkSearch
|
||||
.split(/[\s,\n]+/)
|
||||
.map(t => t.trim().toUpperCase())
|
||||
.filter(t => t.length > 0);
|
||||
|
||||
if (searchTerms.length > 0) {
|
||||
const itemAsin = (item.asin || '').toUpperCase();
|
||||
const itemSku = (item.sku || '').toUpperCase();
|
||||
bulkMatch = searchTerms.some(term =>
|
||||
itemAsin.includes(term) || itemSku.includes(term)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Week Logic: Match "W1", "W2" etc.
|
||||
// item.week is a number (e.g. 1), filter uses strings "W1"
|
||||
const weekStr = item.week ? `W${item.week}` : '';
|
||||
@@ -882,7 +916,7 @@ export const filterData = (
|
||||
const stockMatch = checkStockFilter(item.sku, filters.stock, stockMap);
|
||||
const vendorStockMatch = checkVendorStockFilter(item.asin, filters.vendorStock, vendorStockMap, top50Mode);
|
||||
|
||||
return customerMatch && yearMatch && monthMatch && lineMatch && asinMatch && skuMatch && titleMatch && weekMatch && stockMatch && vendorStockMatch;
|
||||
return customerMatch && yearMatch && monthMatch && lineMatch && asinMatch && skuMatch && titleMatch && bulkMatch && weekMatch && stockMatch && vendorStockMatch;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user