feat: add month switcher to Finance page - fix transactions not showing
All checks were successful
CI / ci (push) Successful in 40s

This commit is contained in:
Cosmo
2026-03-01 05:02:23 +00:00
parent c898c0063c
commit 72915aa6c4
6 changed files with 76 additions and 28 deletions

View File

@@ -8,7 +8,7 @@ const formatDate = (d) => {
return dt.toLocaleDateString("ru-RU", { day: "numeric", month: "long" })
}
export default function TransactionList({ onAdd }) {
export default function TransactionList({ onAdd, month, year }) {
const [transactions, setTransactions] = useState([])
const [categories, setCategories] = useState([])
const [loading, setLoading] = useState(true)
@@ -17,11 +17,12 @@ export default function TransactionList({ onAdd }) {
const [search, setSearch] = useState("")
useEffect(() => {
setLoading(true)
Promise.all([
financeApi.listCategories(),
financeApi.listTransactions({
month: new Date().getMonth() + 1,
year: new Date().getFullYear(),
month,
year,
limit: 100,
}),
])
@@ -31,7 +32,7 @@ export default function TransactionList({ onAdd }) {
})
.catch(console.error)
.finally(() => setLoading(false))
}, [])
}, [month, year])
const filtered = transactions.filter((t) => {
if (filter !== "all" && t.type !== filter) return false
@@ -67,7 +68,6 @@ export default function TransactionList({ onAdd }) {
return (
<div className="space-y-4">
{/* Search */}
<input
className="w-full px-4 py-2.5 rounded-xl bg-gray-100 dark:bg-gray-800 text-sm text-gray-900 dark:text-white placeholder-gray-400 outline-none"
placeholder="Поиск по описанию..."
@@ -75,7 +75,6 @@ export default function TransactionList({ onAdd }) {
onChange={(e) => setSearch(e.target.value)}
/>
{/* Type filter */}
<div className="flex gap-2">
{[
["all", "Все"],
@@ -96,7 +95,6 @@ export default function TransactionList({ onAdd }) {
))}
</div>
{/* Category filter */}
<div className="flex gap-2 overflow-x-auto pb-1">
<button
onClick={() => setCatFilter(null)}
@@ -123,7 +121,6 @@ export default function TransactionList({ onAdd }) {
))}
</div>
{/* Transaction groups */}
{Object.keys(grouped).length === 0 ? (
<div className="card p-12 text-center">
<span className="text-4xl block mb-3">🔍</span>