diff --git a/services/dataProcessor.ts b/services/dataProcessor.ts index 921c2e6..f1bae35 100644 --- a/services/dataProcessor.ts +++ b/services/dataProcessor.ts @@ -2208,16 +2208,24 @@ export const processBuyBoxExcel = async (fileOrBuffer: File | ArrayBuffer): Prom const asinIdx = headers.findIndex(h => { const s = String(h || '').toUpperCase().trim(); - return s === 'ASIN' || s.includes('AMAZON ASIN') || s.includes('IDENTIFIER') || s.includes('PRODUCT ID') || s.includes('SKU'); + return s === 'ASIN' || s.includes('AMAZON ASIN') || s.includes('CHILD ASIN') || s.includes('IDENTIFIER') || s.includes('PRODUCT ID') || s.includes('SKU'); }); const finalAsinIdx = asinIdx !== -1 ? asinIdx : 1; // Default to Col B if not found // Dynamically find the "Issue Type" or "Reason" column let reasonIdx = headers.findIndex(h => { const s = String(h || '').toUpperCase(); - return s.includes('ISSUE TYPE') || s.includes('REASON') || s.includes('BUY BOX STATUS') || s.includes('LBB REASON') || s.includes('ESTADO BB') || s.includes('COMENTARIO') || s.includes('MOTIVO') || s.includes('CAUSA'); + return s.includes('ISSUE TYPE') || s.includes('REASON') || s.includes('BUY BOX STATUS') || s.includes('LBB REASON') || s.includes('ESTADO BB') || s.includes('COMENTARIO') || s.includes('MOTIVO') || s.includes('CAUSA') || s.includes('OBSERVACIONES') || s.includes('DETALLES') || s.includes('JUSTIFICACIÓN') || s.includes('SITUACIÓN') || s.includes('STATUS'); }); + // If still not found, check for exact matches of common Spanish headers + if (reasonIdx === -1) { + reasonIdx = headers.findIndex(h => { + const s = String(h || '').toUpperCase().trim(); + return s === 'COMENTARIOS' || s === 'OBSERVACIONES' || s === 'MOTIVO' || s === 'ESTADO'; + }); + } + // Fallback to previous hardcoded indices if header search fails if (reasonIdx === -1) { if (config.country === 'FR') reasonIdx = 18; @@ -2229,6 +2237,9 @@ export const processBuyBoxExcel = async (fileOrBuffer: File | ArrayBuffer): Prom } console.log(`[BuyBox] Sheet "${sheetName}" (Country: ${config.country}): HeaderRow=${headerRowIdx}, ASIN Col=${finalAsinIdx} ("${headers[finalAsinIdx]}"), Reason Col=${reasonIdx} ("${headers[reasonIdx] || 'N/A'}")`); + if (config.country === 'ES') { + console.log(`[BuyBox Debug] ES Headers found:`, headers); + } // Skip header row and all rows above it for (let i = headerRowIdx + 1; i < jsonData.length; i++) { diff --git a/vite.config.ts b/vite.config.ts index b14abec..5c833cb 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -26,6 +26,24 @@ export default defineConfig(({ mode }) => { changeOrigin: true, rewrite: () => '', followRedirects: true + }, + '/api/fetch-buybox': { + target: 'https://www.dropbox.com/scl/fi/dooz56abib51ifaf42cpx/Buy_Box_tracker.xlsx?rlkey=2sx85bne42fju3d8vekfygzau&dl=1', + changeOrigin: true, + rewrite: () => '', + followRedirects: true + }, + '/api/fetch-ads': { + target: 'https://www.dropbox.com/scl/fi/wng8tep7awhvzd65amwad/Ads-Weekly.xlsx?rlkey=kcmoq8dxgibsb2eb8zz47xvyo&dl=1', + changeOrigin: true, + rewrite: () => '', + followRedirects: true + }, + '/api/fetch-stock': { + target: 'https://www.dropbox.com/scl/fi/jaxc1y01ot7wj4ksswaoe/Item-Availability.xlsx?rlkey=v428jlri5jf1z5ggiebze7ovo&dl=1', + changeOrigin: true, + rewrite: () => '', + followRedirects: true } } },