feat: add Glance Views (GV) to Weekly Sales grid

- Updated WeeklyPivotRow interface and pivotWeeklySalesData to aggregate GV data per week.
- Modified WeeklyGrid.tsx to display GV next to Spend in total header and individual rows.
- Added GV sorting support in the Weekly Sales grid.
This commit is contained in:
Christian Vidal Wolf
2026-01-23 09:35:04 +01:00
parent 7a0375fca7
commit 60330cb2f5
2 changed files with 38 additions and 12 deletions
+4 -1
View File
@@ -1437,6 +1437,7 @@ export interface WeeklyPivotRow {
customer: string;
unitsByWeek: { [weekKey: string]: number }; // Key: "YYYY-WW"
spendByWeek: { [weekKey: string]: number }; // Key: "YYYY-WW"
gvByWeek: { [weekKey: string]: number }; // Key: "YYYY-WW"
}
export const pivotWeeklySalesData = (data: CombinedKPIs[]): {
@@ -1469,7 +1470,8 @@ export const pivotWeeklySalesData = (data: CombinedKPIs[]): {
line: record.line || '',
customer: record.customer || record.marketplace || '',
unitsByWeek: {},
spendByWeek: {}
spendByWeek: {},
gvByWeek: {}
});
}
@@ -1480,6 +1482,7 @@ export const pivotWeeklySalesData = (data: CombinedKPIs[]): {
// Only add cost if we haven't already added it for this ASIN/week
// Since mergeSalesAndAdsData now outputs one record per ASIN/week, this should be clean
row.spendByWeek[weekKey] = (row.spendByWeek[weekKey] || 0) + (record.cost || 0);
row.gvByWeek[weekKey] = (row.gvByWeek[weekKey] || 0) + (record.glanceViews || 0);
}
});