diff --git a/frontend/package.json b/frontend/package.json index b05dbeb..b8994c3 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "aurum-frontend", "private": true, - "version": "0.17.0", + "version": "0.17.1", "type": "module", "scripts": { "dev": "vite", diff --git a/frontend/src/components/dashboard/RecentTransactionsCard.tsx b/frontend/src/components/dashboard/RecentTransactionsCard.tsx index daf2a86..f2ffc43 100644 --- a/frontend/src/components/dashboard/RecentTransactionsCard.tsx +++ b/frontend/src/components/dashboard/RecentTransactionsCard.tsx @@ -18,7 +18,10 @@ export function RecentTransactionsCard({ year, month }: RecentTransactionsCardPr {t("dashboard.recentTransactionsTitle")} - + {t("dashboard.allTransactionsLink")} diff --git a/frontend/src/pages/NetWorthPage.tsx b/frontend/src/pages/NetWorthPage.tsx index 50103fa..04f8825 100644 --- a/frontend/src/pages/NetWorthPage.tsx +++ b/frontend/src/pages/NetWorthPage.tsx @@ -16,7 +16,10 @@ import type { Asset, NetWorthRange } from "@/types"; export function NetWorthPage() { const { t } = useTranslation(); - const [range, setRange] = useState("30d"); + // Defaults to 5 years: a short window can show a dip whenever spending + // briefly outpaces recorded income, which reads as decline even though + // the long-run trend is up — 5y is long enough to make that trend visible. + const [range, setRange] = useState("5y"); const { data: summary, isLoading: isSummaryLoading } = useNetWorthSummary(range); const { data: assets, isLoading: isAssetsLoading } = useAssets(); const deleteAsset = useDeleteAsset(); diff --git a/frontend/src/pages/TransactionsPage.tsx b/frontend/src/pages/TransactionsPage.tsx index 552dabe..d104da0 100644 --- a/frontend/src/pages/TransactionsPage.tsx +++ b/frontend/src/pages/TransactionsPage.tsx @@ -1,4 +1,5 @@ import { useState } from "react"; +import { useSearchParams } from "react-router-dom"; import { Plus } from "lucide-react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/Card"; import { Button } from "@/components/ui/Button"; @@ -16,11 +17,27 @@ import type { Transaction, TransactionType } from "@/types"; const PAGE_SIZE = 20; +/** Clamp a query-param month to 1-12, falling back to `fallback` for + * anything missing or out of range (e.g. a hand-edited URL). */ +function parseMonthParam(value: string | null, fallback: number): number { + const parsed = Number(value); + return Number.isInteger(parsed) ? Math.min(12, Math.max(1, parsed)) : fallback; +} + +function parseYearParam(value: string | null, fallback: number): number { + const parsed = Number(value); + return Number.isInteger(parsed) && parsed > 0 ? parsed : fallback; +} + export function TransactionsPage() { const { t } = useTranslation(); const now = new Date(); - const [year, setYear] = useState(now.getFullYear()); - const [month, setMonth] = useState(now.getMonth() + 1); + // Deep-linked from the Dashboard's "All transactions" link, which carries + // the month/year the user was already looking at (?year=&month=) so this + // page doesn't reset back to the current month. + const [searchParams] = useSearchParams(); + const [year, setYear] = useState(() => parseYearParam(searchParams.get("year"), now.getFullYear())); + const [month, setMonth] = useState(() => parseMonthParam(searchParams.get("month"), now.getMonth() + 1)); const [type, setType] = useState(""); const [categoryId, setCategoryId] = useState(""); const [sort, setSort] = useState("date_desc");