mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 15:55:23 +02:00
debug: Add Spain-specific sheet fallbacks and expose Buy Box data to window.debugBuyBox
This commit is contained in:
@@ -229,7 +229,8 @@ const App: React.FC = () => {
|
|||||||
const buffer = await response.arrayBuffer();
|
const buffer = await response.arrayBuffer();
|
||||||
const data = await processBuyBoxExcel(buffer);
|
const data = await processBuyBoxExcel(buffer);
|
||||||
setBuyBoxLostMap(data);
|
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) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch/parse Buy Box data", error);
|
console.error("Failed to fetch/parse Buy Box data", error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2168,8 +2168,16 @@ export const processBuyBoxExcel = async (fileOrBuffer: File | ArrayBuffer): Prom
|
|||||||
const sheetName = workbook.SheetNames.find(name => {
|
const sheetName = workbook.SheetNames.find(name => {
|
||||||
const n = name.toUpperCase().replace(/[-_ ]/g, '');
|
const n = name.toUpperCase().replace(/[-_ ]/g, '');
|
||||||
const target = config.sheet.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
|
const country = config.country.toUpperCase();
|
||||||
return n === target || n === config.country || (n.includes('BB') && n.includes(config.country));
|
// 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) {
|
if (!sheetName) {
|
||||||
|
|||||||
Reference in New Issue
Block a user