feat: implement bulk search for ASINs/SKUs in DataGrid

This commit is contained in:
Christian Vidal Wolf
2026-02-06 09:22:24 +01:00
parent 3a4410c3b5
commit 62d4903566
4 changed files with 114 additions and 31 deletions
+36 -2
View File
@@ -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;
});
};