diff --git a/src/components/reports/BudgetVsActualTable.tsx b/src/components/reports/BudgetVsActualTable.tsx index 716f7fc..d449bcb 100644 --- a/src/components/reports/BudgetVsActualTable.tsx +++ b/src/components/reports/BudgetVsActualTable.tsx @@ -158,8 +158,8 @@ export default function BudgetVsActualTable({ data }: BudgetVsActualTableProps) const sectionYtdPct = sectionTotals.ytdBudget !== 0 ? sectionTotals.ytdVariation / Math.abs(sectionTotals.ytdBudget) : null; return ( - - + + {section.label} @@ -173,13 +173,13 @@ export default function BudgetVsActualTable({ data }: BudgetVsActualTableProps) @@ -213,8 +213,8 @@ export default function BudgetVsActualTable({ data }: BudgetVsActualTableProps) ); })} - - {t(typeTotalKeys[section.type])} + + {t(typeTotalKeys[section.type])} {cadFormatter(sectionTotals.monthActual)} @@ -240,8 +240,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) => ( + + ))} ) : (