From 4711ab34d4f09bf04976a1f694b60631bfd43a8f Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Sun, 12 Sep 2021 17:07:36 +0200 Subject: [PATCH] BIG-35: fix close drawer when delete expense. --- .../containers/Alerts/Expenses/ExpenseDeleteAlert.js | 12 ++++++++++-- .../Drawers/ExpenseDrawer/ExpenseDrawerActionBar.js | 1 - 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/client/src/containers/Alerts/Expenses/ExpenseDeleteAlert.js b/client/src/containers/Alerts/Expenses/ExpenseDeleteAlert.js index f8604be99..9d3fdaee7 100644 --- a/client/src/containers/Alerts/Expenses/ExpenseDeleteAlert.js +++ b/client/src/containers/Alerts/Expenses/ExpenseDeleteAlert.js @@ -6,6 +6,7 @@ import { AppToaster } from 'components'; import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import withAlertActions from 'containers/Alert/withAlertActions'; +import withDrawerActions from 'containers/Drawer/withDrawerActions'; import { useDeleteExpense } from 'hooks/query'; import { compose } from 'utils'; @@ -20,6 +21,9 @@ function ExpenseDeleteAlert({ // #withAlertStoreConnect isOpen, payload: { expenseId }, + + // #withDrawerActions + closeDrawer, }) { const { mutateAsync: deleteExpenseMutate, isLoading } = useDeleteExpense(); @@ -38,7 +42,7 @@ function ExpenseDeleteAlert({ }), intent: Intent.SUCCESS, }); - closeAlert('expense-delete'); + closeDrawer('expense-drawer'); }) .catch( ({ @@ -57,7 +61,10 @@ function ExpenseDeleteAlert({ }); } }, - ); + ) + .finally(() => { + closeAlert('expense-delete'); + }); }; return ( @@ -81,4 +88,5 @@ function ExpenseDeleteAlert({ export default compose( withAlertStoreConnect(), withAlertActions, + withDrawerActions, )(ExpenseDeleteAlert); diff --git a/client/src/containers/Drawers/ExpenseDrawer/ExpenseDrawerActionBar.js b/client/src/containers/Drawers/ExpenseDrawer/ExpenseDrawerActionBar.js index dd2cc138c..f4472c86c 100644 --- a/client/src/containers/Drawers/ExpenseDrawer/ExpenseDrawerActionBar.js +++ b/client/src/containers/Drawers/ExpenseDrawer/ExpenseDrawerActionBar.js @@ -39,7 +39,6 @@ function ExpenseDrawerActionBar({ // Handle the expense delete action. const handleDeleteExpense = () => { openAlert('expense-delete', { expenseId: expense.id }); - closeDrawer('expense-drawer'); }; return (