From 2b2536bc80b1500352d862154fbf4151bc74ce33 Mon Sep 17 00:00:00 2001 From: medic-bot Date: Mon, 9 Mar 2026 20:48:08 -0400 Subject: [PATCH] fix: address reviewer feedback (#29) - Replace semi-transparent backgrounds on sticky columns with opaque color-mix equivalents so scrolled content is fully hidden - Add opaque background to section header sticky td - Extract IIFE month options in ReportsPage into a useMemo --- .../reports/BudgetVsActualTable.tsx | 18 +++++----- src/pages/ReportsPage.tsx | 34 ++++++++++--------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/components/reports/BudgetVsActualTable.tsx b/src/components/reports/BudgetVsActualTable.tsx index d4a09fb..b2b114b 100644 --- a/src/components/reports/BudgetVsActualTable.tsx +++ b/src/components/reports/BudgetVsActualTable.tsx @@ -206,8 +206,8 @@ export default function BudgetVsActualTable({ data }: BudgetVsActualTableProps) const sectionYtdPct = sectionTotals.ytdBudget !== 0 ? sectionTotals.ytdVariation / Math.abs(sectionTotals.ytdBudget) : null; return ( - - + + {section.label} @@ -220,11 +220,11 @@ export default function BudgetVsActualTable({ data }: BudgetVsActualTableProps) - + ); })} - - {t(typeTotalKeys[section.type])} + + {t(typeTotalKeys[section.type])} {cadFormatter(sectionTotals.monthActual)} @@ -283,8 +283,8 @@ export default function BudgetVsActualTable({ data }: BudgetVsActualTableProps) ); })} {/* Grand totals */} - - {t("common.total")} + + {t("common.total")} {cadFormatter(totals.monthActual)} diff --git a/src/pages/ReportsPage.tsx b/src/pages/ReportsPage.tsx index b654fd5..0102b19 100644 --- a/src/pages/ReportsPage.tsx +++ b/src/pages/ReportsPage.tsx @@ -92,6 +92,19 @@ export default function ReportsPage() { return []; }, [state.tab, state.categorySpending, state.categoryOverTime]); + const monthOptions = useMemo(() => { + const now = new Date(); + const currentMonth = now.getMonth(); + const currentYear = now.getFullYear(); + return Array.from({ length: 24 }, (_, i) => { + const d = new Date(currentYear, currentMonth - i, 1); + const y = d.getFullYear(); + const m = d.getMonth() + 1; + const label = new Intl.DateTimeFormat(i18n.language, { month: "long", year: "numeric" }).format(d); + return { key: `${y}-${m}`, value: `${y}-${m}`, label: label.charAt(0).toUpperCase() + label.slice(1) }; + }); + }, [i18n.language]); + const hasCategories = ["byCategory", "overTime"].includes(state.tab) && filterCategories.length > 0; const showFilterPanel = hasCategories || (state.tab === "trends" && sources.length > 1); @@ -110,22 +123,11 @@ export default function ReportsPage() { }} className="text-2xl font-bold bg-[var(--card)] border border-[var(--border)] rounded-lg px-3 py-1 cursor-pointer hover:bg-[var(--muted)] transition-colors" > - {(() => { - const now = new Date(); - const currentMonth = now.getMonth(); // 0-based - const currentYear = now.getFullYear(); - return Array.from({ length: 24 }, (_, i) => { - const d = new Date(currentYear, currentMonth - i, 1); - const y = d.getFullYear(); - const m = d.getMonth() + 1; - const label = new Intl.DateTimeFormat(i18n.language, { month: "long", year: "numeric" }).format(d); - return ( - - ); - }); - })()} + {monthOptions.map((opt) => ( + + ))} ) : (