mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 15:35:22 +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 {
|
return {
|
||||||
id: sale.id,
|
id: sale.id,
|
||||||
marketplace: sale.customer,
|
marketplace: sale.customer,
|
||||||
|
customer: sale.customer,
|
||||||
month: sale.month,
|
month: sale.month,
|
||||||
year: sale.year,
|
year: sale.year,
|
||||||
asin: sale.asin,
|
asin: sale.asin,
|
||||||
@@ -1022,13 +1023,17 @@ export const pivotSalesData = (data: any[], dimensions: string[] = ['title', 'cu
|
|||||||
|
|
||||||
data.forEach(record => {
|
data.forEach(record => {
|
||||||
// Group by Dynamic Dimensions
|
// 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('||');
|
const key = keyParts.join('||');
|
||||||
|
|
||||||
if (!map.has(key)) {
|
if (!map.has(key)) {
|
||||||
map.set(key, {
|
map.set(key, {
|
||||||
id: key,
|
id: key,
|
||||||
customer: dimensions.includes('customer') ? record.customer : '',
|
customer: dimensions.includes('customer') ? (record.customer || record.marketplace || '') : '',
|
||||||
line: dimensions.includes('line') ? record.line : '',
|
line: dimensions.includes('line') ? record.line : '',
|
||||||
title: dimensions.includes('title') ? record.title : '',
|
title: dimensions.includes('title') ? record.title : '',
|
||||||
articleName: dimensions.includes('articleName') ? record.articleName : '',
|
articleName: dimensions.includes('articleName') ? record.articleName : '',
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ export interface AdsRecord {
|
|||||||
export interface CombinedKPIs {
|
export interface CombinedKPIs {
|
||||||
id: string;
|
id: string;
|
||||||
marketplace: string;
|
marketplace: string;
|
||||||
|
customer: string; // Added for consistency with SalesRecord
|
||||||
month: string;
|
month: string;
|
||||||
year: number;
|
year: number;
|
||||||
asin: string;
|
asin: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user