debug: Add Spain-specific sheet fallbacks and expose Buy Box data to window.debugBuyBox

This commit is contained in:
Christian Vidal Wolf
2026-02-05 08:52:49 +01:00
parent aeefd76496
commit 9f9556af2a
2 changed files with 12 additions and 3 deletions
+2 -1
View File
@@ -229,7 +229,8 @@ const App: React.FC = () => {
const buffer = await response.arrayBuffer();
const data = await processBuyBoxExcel(buffer);
setBuyBoxLostMap(data);
console.log('[App] Successfully loaded Buy Box lost data for', data.size, 'ASINs');
(window as any).debugBuyBox = data;
console.log('[App] Successfully loaded Buy Box lost data for', data.size, 'ASINs. Access via window.debugBuyBox');
} catch (error) {
console.error("Failed to fetch/parse Buy Box data", error);
}
+10 -2
View File
@@ -2168,8 +2168,16 @@ export const processBuyBoxExcel = async (fileOrBuffer: File | ArrayBuffer): Prom
const sheetName = workbook.SheetNames.find(name => {
const n = name.toUpperCase().replace(/[-_ ]/g, '');
const target = config.sheet.toUpperCase().replace(/[-_ ]/g, '');
// Also match if the sheet is just the country code or contains 'BB' and the country code
return n === target || n === config.country || (n.includes('BB') && n.includes(config.country));
const country = config.country.toUpperCase();
// Match if:
// 1. Exact pattern (BB_ES)
// 2. Just the country code (ES)
// 3. Contains 'BB' and the country code
// 4. Special cases for Spain (SPAIN, ESPAÑA)
return n === target ||
n === country ||
(n.includes('BB') && n.includes(country)) ||
(country === 'ES' && (n.includes('SPAIN') || n.includes('ESPAÑA') || n.includes('ESPANA')));
});
if (!sheetName) {