From e8091d95f60065948b38badda6c6be69a46ef32d Mon Sep 17 00:00:00 2001 From: Sahilagarwal623 Date: Sat, 25 Oct 2025 15:34:24 +0530 Subject: [PATCH 1/2] fixed export to csv button --- frontend/src/pages/TransactionsPage.jsx | 131 ++++++++++++------------ 1 file changed, 68 insertions(+), 63 deletions(-) diff --git a/frontend/src/pages/TransactionsPage.jsx b/frontend/src/pages/TransactionsPage.jsx index cc7f900..0c26772 100644 --- a/frontend/src/pages/TransactionsPage.jsx +++ b/frontend/src/pages/TransactionsPage.jsx @@ -42,7 +42,7 @@ const TransactionsPage = () => { const [isCategoryModalOpen, setIsCategoryModalOpen] = useState(false); const { currency } = useCurrency(); const isInitialMount = useRef(true); - const allCategories = [...new Set([...expenseCategories, ...incomeCategories])]; + const allCategories = [...new Set([...expenseCategories, ...incomeCategories])]; const fetchData = useCallback(async (currentSearchTerm = searchTerm) => { if (isInitialMount.current) { @@ -101,7 +101,7 @@ const TransactionsPage = () => { if (isInitialMount.current) { fetchData(); // Fetch on initial mount } else { - // Debounced search is handled separately in handleSearchChange + // Debounced search is handled separately in handleSearchChange if (!debounceTimer.current) { fetchData(); } @@ -138,7 +138,7 @@ const TransactionsPage = () => { setDateTo(''); setPage(1); }; - + const hasActiveFilters = searchTerm || typeFilter !== 'all' || categoryFilter !== 'all' || dateFrom || dateTo; const handleOpenTransactionModal = (transaction = null) => { @@ -193,19 +193,19 @@ const TransactionsPage = () => { }; const toggleSelect = (id) => { - setSelectedTransactionIds(prev => + setSelectedTransactionIds(prev => prev.includes(id) ? prev.filter(x => x !== id) : [...prev, id] ); }; - + const handleBulkDelete = async () => { if (!selectedTransactionIds.length) return; - + const confirmMessage = `Are you sure you want to permanently delete these ${selectedTransactionIds.length} transactions? This action cannot be undone.`; if (window.confirm(confirmMessage)) { try { - await api.delete('/transactions/bulk', { - data: { transactionIds: selectedTransactionIds } + await api.delete('/transactions/bulk', { + data: { transactionIds: selectedTransactionIds } }); setSelectedTransactionIds([]); fetchData(); // Refetch data @@ -240,7 +240,7 @@ const TransactionsPage = () => {

Transactions

- {selectedTransactionIds.length > 0 && + {selectedTransactionIds.length > 0 && @@ -252,9 +252,14 @@ const TransactionsPage = () => { + Add Transaction @@ -336,11 +341,11 @@ const TransactionsPage = () => { ) : (
- {transactions.length > 0 ? ( - - - - + ))} + +
+ {transactions.length > 0 ? ( + + + + - - - - - - - - - - {transactions.map((tx) => ( - - + + + + + + + + + {transactions.map((tx) => ( + + - - - - - - + + + + + - - ))} - -
{ onChange={() => setSelectedTransactionIds(selectedTransactionIds.length ? [] : transactions.map(t => t._id))} /> NameCategoryAmountDateNoteActions
+ NameCategoryAmountDateNoteActions
{ onChange={() => toggleSelect(tx._id)} /> {tx.name}{tx.category} - {tx.isIncome ? '+' : '-'}{new Intl.NumberFormat('en-US', { - style: 'currency', - currency: currency.code, - }).format(tx.cost)} - {new Date(tx.addedOn).toLocaleDateString()} - - + {tx.name}{tx.category} + {tx.isIncome ? '+' : '-'}{new Intl.NumberFormat('en-US', { + style: 'currency', + currency: currency.code, + }).format(tx.cost)} + {new Date(tx.addedOn).toLocaleDateString()} + +
+
) : ( -
- -
- )} +
+ +
+ )}
)} {!loading && totalPages > 1 && (
- - +
Page {page} of {totalPages}
- -