mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 12:35:24 +02:00
fix: restore customer field in grid by normalizing CombinedKPIs fields
This commit is contained in:
@@ -507,6 +507,7 @@ export const mergeSalesAndAdsData = (salesData: SalesRecord[], adsData: AdsRecor
|
||||
return {
|
||||
id: sale.id,
|
||||
marketplace: sale.customer,
|
||||
customer: sale.customer,
|
||||
month: sale.month,
|
||||
year: sale.year,
|
||||
asin: sale.asin,
|
||||
@@ -1022,13 +1023,17 @@ export const pivotSalesData = (data: any[], dimensions: string[] = ['title', 'cu
|
||||
|
||||
data.forEach(record => {
|
||||
// Group by Dynamic Dimensions
|
||||
const keyParts = dimensions.map(dim => String(record[dim] || ''));
|
||||
// Use a fallback for 'customer' dimension as some records use 'marketplace'
|
||||
const keyParts = dimensions.map(dim => {
|
||||
if (dim === 'customer') return String(record.customer || record.marketplace || '');
|
||||
return String(record[dim] || '');
|
||||
});
|
||||
const key = keyParts.join('||');
|
||||
|
||||
if (!map.has(key)) {
|
||||
map.set(key, {
|
||||
id: key,
|
||||
customer: dimensions.includes('customer') ? record.customer : '',
|
||||
customer: dimensions.includes('customer') ? (record.customer || record.marketplace || '') : '',
|
||||
line: dimensions.includes('line') ? record.line : '',
|
||||
title: dimensions.includes('title') ? record.title : '',
|
||||
articleName: dimensions.includes('articleName') ? record.articleName : '',
|
||||
|
||||
Reference in New Issue
Block a user