From 3d5994bf30680c15a86b7f4526d305991496419f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Elisi=C3=A1rio=20Couto?=
Date: Mon, 8 Dec 2025 21:30:57 +0000
Subject: [PATCH] Fix lint issues.
---
frontend/src/components/TransactionsTable.tsx | 61 ++++++++++---------
1 file changed, 32 insertions(+), 29 deletions(-)
diff --git a/frontend/src/components/TransactionsTable.tsx b/frontend/src/components/TransactionsTable.tsx
index a8a90b8..bd4152a 100644
--- a/frontend/src/components/TransactionsTable.tsx
+++ b/frontend/src/components/TransactionsTable.tsx
@@ -126,7 +126,10 @@ export default function TransactionsTable() {
placeholderData: (previousData) => previousData,
});
- const transactions = transactionsResponse?.data || [];
+ const transactions = useMemo(
+ () => transactionsResponse?.data || [],
+ [transactionsResponse],
+ );
const pagination = useMemo(
() =>
transactionsResponse
@@ -142,6 +145,31 @@ export default function TransactionsTable() {
[transactionsResponse],
);
+ // Calculate stats from current page transactions, memoized for performance
+ const stats = useMemo(() => {
+ const totalIncome = transactions
+ .filter((t: Transaction) => t.transaction_value > 0)
+ .reduce((sum: number, t: Transaction) => sum + t.transaction_value, 0);
+
+ const totalExpenses = Math.abs(
+ transactions
+ .filter((t: Transaction) => t.transaction_value < 0)
+ .reduce((sum: number, t: Transaction) => sum + t.transaction_value, 0)
+ );
+
+ // Get currency from first transaction, fallback to EUR
+ const displayCurrency = transactions.length > 0 ? transactions[0].transaction_currency : "EUR";
+
+ return {
+ totalCount: pagination?.total || 0,
+ pageCount: transactions.length,
+ totalIncome,
+ totalExpenses,
+ netChange: totalIncome - totalExpenses,
+ displayCurrency,
+ };
+ }, [transactions, pagination]);
+
// Check if search is currently debouncing
const isSearchLoading = filterState.searchTerm !== debouncedSearchTerm;
@@ -356,31 +384,6 @@ export default function TransactionsTable() {
);
}
- // Calculate stats from current page transactions, memoized for performance
- const { totalIncome, totalExpenses, displayCurrency, stats } = useMemo(() => {
- const totalIncome = transactions
- .filter((t: Transaction) => t.transaction_value > 0)
- .reduce((sum: number, t: Transaction) => sum + t.transaction_value, 0);
-
- const totalExpenses = Math.abs(
- transactions
- .filter((t: Transaction) => t.transaction_value < 0)
- .reduce((sum: number, t: Transaction) => sum + t.transaction_value, 0)
- );
-
- // Get currency from first transaction, fallback to EUR
- const displayCurrency = transactions.length > 0 ? transactions[0].transaction_currency : "EUR";
-
- const stats = {
- totalCount: pagination?.total || 0,
- pageCount: transactions.length,
- totalIncome,
- totalExpenses,
- netChange: totalIncome - totalExpenses,
- };
-
- return { totalIncome, totalExpenses, displayCurrency, stats };
- }, [transactions, pagination]);
return (
{/* New FilterBar */}
@@ -418,7 +421,7 @@ export default function TransactionsTable() {
Income
- +{formatCurrency(stats.totalIncome, displayCurrency)}
+ +{formatCurrency(stats.totalIncome, stats.displayCurrency)}
@@ -432,7 +435,7 @@ export default function TransactionsTable() {
Expenses
- -{formatCurrency(stats.totalExpenses, displayCurrency)}
+ -{formatCurrency(stats.totalExpenses, stats.displayCurrency)}
@@ -451,7 +454,7 @@ export default function TransactionsTable() {
}`}
>
{stats.netChange >= 0 ? "+" : ""}
- {formatCurrency(stats.netChange, displayCurrency)}
+ {formatCurrency(stats.netChange, stats.displayCurrency)}
{stats.netChange >= 0 ? (