diff --git a/App.tsx b/App.tsx index a76ba95..3ddc7ec 100644 --- a/App.tsx +++ b/App.tsx @@ -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); } diff --git a/services/dataProcessor.ts b/services/dataProcessor.ts index aa08150..921c2e6 100644 --- a/services/dataProcessor.ts +++ b/services/dataProcessor.ts @@ -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) {