mirror of
https://github.com/Zproger/Aurum.git
synced 2026-11-18 08:02:49 +07:00
feat: add year switcher to Dashboard, Transactions and Budget
Year was previously hardcoded to the current year on all three pages (useState with no setter) — only the month could be changed via MonthSelector, making it impossible to look at or compare older years even though transaction history goes back further than the current year. Adds GET /transactions/years (contiguous range from the earliest transaction through the current year) and a YearSelector component matching MonthSelector's style, wired into all three pages alongside a real year useState.
This commit is contained in:
32
frontend/src/components/layout/YearSelector.tsx
Normal file
32
frontend/src/components/layout/YearSelector.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface YearSelectorProps {
|
||||
years: number[];
|
||||
year: number;
|
||||
onChange: (year: number) => void;
|
||||
}
|
||||
|
||||
export function YearSelector({ years, year, onChange }: YearSelectorProps) {
|
||||
return (
|
||||
<div className="flex gap-2 overflow-x-auto pb-1 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
|
||||
{years.map((value) => {
|
||||
const active = value === year;
|
||||
return (
|
||||
<button
|
||||
key={value}
|
||||
type="button"
|
||||
onClick={() => onChange(value)}
|
||||
className={cn(
|
||||
"shrink-0 rounded-full border px-3.5 py-1.5 text-sm font-medium transition-colors",
|
||||
active
|
||||
? "border-text-primary bg-text-primary text-surface-1"
|
||||
: "border-border bg-surface-1 text-text-secondary hover:bg-surface-2"
|
||||
)}
|
||||
>
|
||||
{value}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user