From d06dd7a8587e9bf43a7cd471ee48092127d5fb7d Mon Sep 17 00:00:00 2001 From: le king fu Date: Tue, 14 Apr 2026 14:52:34 -0400 Subject: [PATCH] =?UTF-8?q?feat:=20trends=20report=20=E2=80=94=20global=20?= =?UTF-8?q?flow=20+=20by=20category=20with=20view=20toggle=20(#72)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Flesh out ReportsTrendsPage with internal subview toggle (global / byCategory) and ViewModeToggle (storage key reports-viewmode-trends) - Reuse existing MonthlyTrendsChart/Table and CategoryOverTimeChart/Table without modification; wire them through useTrends + useReportsPeriod so the URL period is respected - Add reports.trends.subviewGlobal / subviewByCategory keys in FR + EN Fixes #72 Co-Authored-By: Claude Opus 4.6 (1M context) --- src/i18n/locales/en.json | 4 ++ src/i18n/locales/fr.json | 4 ++ src/pages/ReportsTrendsPage.tsx | 111 +++++++++++++++++++++++++++++++- 3 files changed, 116 insertions(+), 3 deletions(-) diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 3a56138..610882e 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -399,6 +399,10 @@ "categoryZoom": "Category Analysis", "categoryZoomDescription": "Zoom in on a single category" }, + "trends": { + "subviewGlobal": "Global flow", + "subviewByCategory": "By category" + }, "highlights": { "balances": "Balances", "netBalanceCurrent": "This month", diff --git a/src/i18n/locales/fr.json b/src/i18n/locales/fr.json index 4033c35..3386bd6 100644 --- a/src/i18n/locales/fr.json +++ b/src/i18n/locales/fr.json @@ -399,6 +399,10 @@ "categoryZoom": "Analyse par catégorie", "categoryZoomDescription": "Zoom sur une catégorie" }, + "trends": { + "subviewGlobal": "Flux global", + "subviewByCategory": "Par catégorie" + }, "highlights": { "balances": "Soldes", "netBalanceCurrent": "Ce mois-ci", diff --git a/src/pages/ReportsTrendsPage.tsx b/src/pages/ReportsTrendsPage.tsx index 74849cc..65b3b9b 100644 --- a/src/pages/ReportsTrendsPage.tsx +++ b/src/pages/ReportsTrendsPage.tsx @@ -1,11 +1,116 @@ +import { useState, useCallback } from "react"; import { useTranslation } from "react-i18next"; +import { Link } from "react-router-dom"; +import { ArrowLeft } from "lucide-react"; +import PeriodSelector from "../components/dashboard/PeriodSelector"; +import MonthlyTrendsChart from "../components/reports/MonthlyTrendsChart"; +import MonthlyTrendsTable from "../components/reports/MonthlyTrendsTable"; +import CategoryOverTimeChart from "../components/reports/CategoryOverTimeChart"; +import CategoryOverTimeTable from "../components/reports/CategoryOverTimeTable"; +import ViewModeToggle, { readViewMode, type ViewMode } from "../components/reports/ViewModeToggle"; +import { useTrends } from "../hooks/useTrends"; +import { useReportsPeriod } from "../hooks/useReportsPeriod"; +import type { CategoryBreakdownItem } from "../shared/types"; + +const STORAGE_KEY = "reports-viewmode-trends"; export default function ReportsTrendsPage() { const { t } = useTranslation(); + const { period, setPeriod, from, to, setCustomDates } = useReportsPeriod(); + const { subView, setSubView, monthlyTrends, categoryOverTime, isLoading, error } = useTrends(); + const [viewMode, setViewMode] = useState(() => readViewMode(STORAGE_KEY)); + const [hiddenCategories, setHiddenCategories] = useState>(new Set()); + + const preserveSearch = typeof window !== "undefined" ? window.location.search : ""; + + const toggleHidden = useCallback((name: string) => { + setHiddenCategories((prev) => { + const next = new Set(prev); + if (next.has(name)) next.delete(name); + else next.add(name); + return next; + }); + }, []); + + const showAll = useCallback(() => setHiddenCategories(new Set()), []); + // viewDetails not used in trends view — transactions details are accessed from category zoom. + const noOpDetails = useCallback((_item: CategoryBreakdownItem) => {}, []); + return ( -
-

{t("reports.hub.trends")}

-

{t("common.underConstruction")}

+
+
+ + + +

{t("reports.hub.trends")}

+
+ +
+ +
+
+ + +
+ +
+
+ + {error && ( +
+ {error} +
+ )} + + {subView === "global" ? ( + viewMode === "chart" ? ( + + ) : ( + + ) + ) : viewMode === "chart" ? ( + + ) : ( + + )}
); } -- 2.45.2