mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 14:15:23 +02:00
feat: force ASIN and SKU columns in Grid exports
This commit is contained in:
@@ -1541,14 +1541,18 @@ export const generateXLSX = (rows: PivotRow[], dimensions: string[], years: stri
|
|||||||
const flatData = rows.map(row => {
|
const flatData = rows.map(row => {
|
||||||
const flatRow: any = {};
|
const flatRow: any = {};
|
||||||
|
|
||||||
// Add Dimension Columns
|
// Always ensure ASIN and SKU are exported as foundational identifiers
|
||||||
|
flatRow['ASIN'] = row.asin || '-';
|
||||||
|
flatRow['SKU'] = row.sku || '-';
|
||||||
|
|
||||||
|
// Add User Selected Dimension Columns
|
||||||
dimensions.forEach(dim => {
|
dimensions.forEach(dim => {
|
||||||
|
if (dim.toLowerCase() === 'asin' || dim.toLowerCase() === 'sku') return; // Skip if already explicitly set
|
||||||
|
|
||||||
let header = dim;
|
let header = dim;
|
||||||
if (dim === 'line') header = 'Product Line';
|
if (dim === 'line') header = 'Product Line';
|
||||||
if (dim === 'title') header = 'Title';
|
if (dim === 'title') header = 'Title';
|
||||||
if (dim === 'customer') header = 'Customer';
|
if (dim === 'customer') header = 'Customer';
|
||||||
if (dim === 'sku' || dim === 'SKU') header = 'SKU';
|
|
||||||
if (dim === 'asin' || dim === 'ASIN') header = 'ASIN';
|
|
||||||
|
|
||||||
flatRow[header] = row[dim as keyof PivotRow];
|
flatRow[header] = row[dim as keyof PivotRow];
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user