mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 12:25:22 +02:00
fix: include ads-only ASINs in merge and use unfiltered rows for totals
1. Changed weekTotals to use 'rows' instead of 'filteredRows' so totals always show complete sums regardless of search/growth filters 2. Added second pass in mergeSalesAndAdsData to include ads records for ASINs that have ad spend but no corresponding sales data
This commit is contained in:
@@ -119,18 +119,18 @@ const WeeklyGrid: React.FC<WeeklyGridProps> = ({ data }) => {
|
||||
|
||||
const totalPages = Math.ceil(sortedRows.length / ROWS_PER_PAGE);
|
||||
|
||||
// Calculate totals per week
|
||||
// Calculate totals per week - use unfiltered 'rows' to show complete totals
|
||||
const weekTotals = useMemo(() => {
|
||||
const totals: { [weekKey: string]: { units: number, spend: number } } = {};
|
||||
weeks.forEach(week => {
|
||||
totals[week] = filteredRows.reduce((acc, row) => {
|
||||
totals[week] = rows.reduce((acc, row) => {
|
||||
acc.units += (row.unitsByWeek[week] || 0);
|
||||
acc.spend += (row.spendByWeek[week] || 0);
|
||||
return acc;
|
||||
}, { units: 0, spend: 0 });
|
||||
});
|
||||
return totals;
|
||||
}, [filteredRows, weeks]);
|
||||
}, [rows, weeks]);
|
||||
|
||||
const renderGrowth = (current: number, previous: number) => {
|
||||
if (!previous || previous === 0) return null;
|
||||
|
||||
Reference in New Issue
Block a user