From 9a34f3e28364dfa62fb1a6cbb13144904698a660 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Mon, 12 Aug 2024 10:11:40 +0200 Subject: [PATCH] fix: invalidate account cache on bulk uncategorizing --- .../AccountTransactions/AccountTransactionsDataTable.tsx | 7 ++++--- .../alerts/UncategorizeBankTransactionsBulkAlert.tsx | 2 +- packages/webapp/src/hooks/query/bank-transactions.ts | 9 +++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/webapp/src/containers/CashFlow/AccountTransactions/AccountTransactionsDataTable.tsx b/packages/webapp/src/containers/CashFlow/AccountTransactions/AccountTransactionsDataTable.tsx index 660749175..f2e4ddfe5 100644 --- a/packages/webapp/src/containers/CashFlow/AccountTransactions/AccountTransactionsDataTable.tsx +++ b/packages/webapp/src/containers/CashFlow/AccountTransactions/AccountTransactionsDataTable.tsx @@ -103,9 +103,10 @@ function AccountTransactionsDataTable({ // Handle selected rows change. const handleSelectedRowsChange = (selected) => { - const selectedIds = selected?.map( - (row) => row.original.uncategorized_transaction_id, - ); + const selectedIds = selected + ?.filter((row) => row.original.uncategorized_transaction_id) + ?.map((row) => row.original.uncategorized_transaction_id); + setCategorizedTransactionsSelected(selectedIds); }; diff --git a/packages/webapp/src/containers/CashFlow/AccountTransactions/alerts/UncategorizeBankTransactionsBulkAlert.tsx b/packages/webapp/src/containers/CashFlow/AccountTransactions/alerts/UncategorizeBankTransactionsBulkAlert.tsx index ae2ad77fd..4b211f21a 100644 --- a/packages/webapp/src/containers/CashFlow/AccountTransactions/alerts/UncategorizeBankTransactionsBulkAlert.tsx +++ b/packages/webapp/src/containers/CashFlow/AccountTransactions/alerts/UncategorizeBankTransactionsBulkAlert.tsx @@ -57,7 +57,7 @@ function UncategorizeBankTransactionsBulkAlert({ >

Are you sure want to uncategorize the selected bank transactions, this - action is not revertable but you can always categorize them again? + action is not reversible but you can always categorize them again?

); diff --git a/packages/webapp/src/hooks/query/bank-transactions.ts b/packages/webapp/src/hooks/query/bank-transactions.ts index 8604f75be..166d79447 100644 --- a/packages/webapp/src/hooks/query/bank-transactions.ts +++ b/packages/webapp/src/hooks/query/bank-transactions.ts @@ -47,16 +47,17 @@ export function useUncategorizeTransactionsBulkAction( t.CASHFLOW_ACCOUNT_UNCATEGORIZED_TRANSACTIONS_INFINITY, ); // Invalidate the account transactions. - queryClient.invalidateQueries( - t.CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY - ); - // invalidate bank account summary. + queryClient.invalidateQueries(t.CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY); + + // Invalidate bank account summary. queryClient.invalidateQueries(BANK_QUERY_KEY.BANK_ACCOUNT_SUMMARY_META); // Invalidate the recognized transactions. queryClient.invalidateQueries([ BANK_QUERY_KEY.RECOGNIZED_BANK_TRANSACTIONS_INFINITY, ]); + // Invalidate the account. + queryClient.invalidateQueries(t.ACCOUNT); }, ...options, },