mirror of
https://github.com/elisiariocouto/leggen.git
synced 2025-12-18 00:59:21 +00:00
Update frontend/src/components/TransactionsTable.tsx
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -356,7 +356,8 @@ export default function TransactionsTable() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate stats from current page transactions
|
// Calculate stats from current page transactions, memoized for performance
|
||||||
|
const { totalIncome, totalExpenses, displayCurrency, stats } = useMemo(() => {
|
||||||
const totalIncome = transactions
|
const totalIncome = transactions
|
||||||
.filter((t: Transaction) => t.transaction_value > 0)
|
.filter((t: Transaction) => t.transaction_value > 0)
|
||||||
.reduce((sum: number, t: Transaction) => sum + t.transaction_value, 0);
|
.reduce((sum: number, t: Transaction) => sum + t.transaction_value, 0);
|
||||||
@@ -378,6 +379,8 @@ export default function TransactionsTable() {
|
|||||||
netChange: totalIncome - totalExpenses,
|
netChange: totalIncome - totalExpenses,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return { totalIncome, totalExpenses, displayCurrency, stats };
|
||||||
|
}, [transactions, pagination]);
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6 max-w-full">
|
<div className="space-y-6 max-w-full">
|
||||||
{/* New FilterBar */}
|
{/* New FilterBar */}
|
||||||
|
|||||||
Reference in New Issue
Block a user