mirror of
https://github.com/elisiariocouto/leggen.git
synced 2025-12-13 09:02:23 +00:00
Fix lint issues.
This commit is contained in:
committed by
Elisiário Couto
parent
edbc1cb39e
commit
3d5994bf30
@@ -126,7 +126,10 @@ export default function TransactionsTable() {
|
|||||||
placeholderData: (previousData) => previousData,
|
placeholderData: (previousData) => previousData,
|
||||||
});
|
});
|
||||||
|
|
||||||
const transactions = transactionsResponse?.data || [];
|
const transactions = useMemo(
|
||||||
|
() => transactionsResponse?.data || [],
|
||||||
|
[transactionsResponse],
|
||||||
|
);
|
||||||
const pagination = useMemo(
|
const pagination = useMemo(
|
||||||
() =>
|
() =>
|
||||||
transactionsResponse
|
transactionsResponse
|
||||||
@@ -142,6 +145,31 @@ export default function TransactionsTable() {
|
|||||||
[transactionsResponse],
|
[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
|
// Check if search is currently debouncing
|
||||||
const isSearchLoading = filterState.searchTerm !== debouncedSearchTerm;
|
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 (
|
return (
|
||||||
<div className="space-y-6 max-w-full">
|
<div className="space-y-6 max-w-full">
|
||||||
{/* New FilterBar */}
|
{/* New FilterBar */}
|
||||||
@@ -418,7 +421,7 @@ export default function TransactionsTable() {
|
|||||||
Income
|
Income
|
||||||
</p>
|
</p>
|
||||||
<BlurredValue className="text-2xl font-bold text-green-600 mt-1 block">
|
<BlurredValue className="text-2xl font-bold text-green-600 mt-1 block">
|
||||||
+{formatCurrency(stats.totalIncome, displayCurrency)}
|
+{formatCurrency(stats.totalIncome, stats.displayCurrency)}
|
||||||
</BlurredValue>
|
</BlurredValue>
|
||||||
</div>
|
</div>
|
||||||
<TrendingUp className="h-8 w-8 text-green-600 opacity-50" />
|
<TrendingUp className="h-8 w-8 text-green-600 opacity-50" />
|
||||||
@@ -432,7 +435,7 @@ export default function TransactionsTable() {
|
|||||||
Expenses
|
Expenses
|
||||||
</p>
|
</p>
|
||||||
<BlurredValue className="text-2xl font-bold text-red-600 mt-1 block">
|
<BlurredValue className="text-2xl font-bold text-red-600 mt-1 block">
|
||||||
-{formatCurrency(stats.totalExpenses, displayCurrency)}
|
-{formatCurrency(stats.totalExpenses, stats.displayCurrency)}
|
||||||
</BlurredValue>
|
</BlurredValue>
|
||||||
</div>
|
</div>
|
||||||
<TrendingDown className="h-8 w-8 text-red-600 opacity-50" />
|
<TrendingDown className="h-8 w-8 text-red-600 opacity-50" />
|
||||||
@@ -451,7 +454,7 @@ export default function TransactionsTable() {
|
|||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{stats.netChange >= 0 ? "+" : ""}
|
{stats.netChange >= 0 ? "+" : ""}
|
||||||
{formatCurrency(stats.netChange, displayCurrency)}
|
{formatCurrency(stats.netChange, stats.displayCurrency)}
|
||||||
</BlurredValue>
|
</BlurredValue>
|
||||||
</div>
|
</div>
|
||||||
{stats.netChange >= 0 ? (
|
{stats.netChange >= 0 ? (
|
||||||
|
|||||||
Reference in New Issue
Block a user