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:
Christian Vidal Wolf
2026-01-22 09:24:40 +01:00
parent 8de4521fbe
commit 8b47ab844e
2 changed files with 47 additions and 3 deletions
+3 -3
View File
@@ -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;