feat: add month switcher to Finance page - fix transactions not showing
All checks were successful
CI / ci (push) Successful in 40s
All checks were successful
CI / ci (push) Successful in 40s
This commit is contained in:
@@ -12,18 +12,18 @@ const COLORS = [
|
||||
|
||||
const fmt = (n) => Number(n).toLocaleString("ru-RU") + " ₽"
|
||||
|
||||
export default function FinanceDashboard() {
|
||||
export default function FinanceDashboard({ month, year }) {
|
||||
const [summary, setSummary] = useState(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
const now = new Date()
|
||||
setLoading(true)
|
||||
financeApi
|
||||
.getSummary({ month: now.getMonth() + 1, year: now.getFullYear() })
|
||||
.getSummary({ month, year })
|
||||
.then(setSummary)
|
||||
.catch(console.error)
|
||||
.finally(() => setLoading(false))
|
||||
}, [])
|
||||
}, [month, year])
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
@@ -63,7 +63,6 @@ export default function FinanceDashboard() {
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Balance Card */}
|
||||
<div className="card p-6 bg-gradient-to-br from-primary-950 to-primary-800 text-white">
|
||||
<p className="text-sm opacity-70">Баланс за месяц</p>
|
||||
<p className="text-3xl font-bold mt-1">{fmt(summary.balance)}</p>
|
||||
@@ -83,7 +82,6 @@ export default function FinanceDashboard() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Top Categories */}
|
||||
{expenseCategories.length > 0 && (
|
||||
<div className="card p-5">
|
||||
<h3 className="font-display font-bold text-gray-900 dark:text-white mb-4">
|
||||
@@ -120,7 +118,6 @@ export default function FinanceDashboard() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Donut Chart */}
|
||||
{pieData.length > 0 && (
|
||||
<div className="card p-5">
|
||||
<h3 className="font-display font-bold text-gray-900 dark:text-white mb-4">
|
||||
@@ -168,7 +165,6 @@ export default function FinanceDashboard() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Daily Line Chart */}
|
||||
{dailyData.length > 0 && (
|
||||
<div className="card p-5">
|
||||
<h3 className="font-display font-bold text-gray-900 dark:text-white mb-4">
|
||||
|
||||
Reference in New Issue
Block a user