From f7b29a260e09fa599b0057e23a8933c453e6aa83 Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Sun, 12 Sep 2021 16:57:08 +0200 Subject: [PATCH] BIG-33: fix close drawer when delete bill. --- client/src/containers/Alerts/Bills/BillDeleteAlert.js | 8 +++++++- .../Drawers/BillDrawer/BillDetailActionsBar.js | 9 +++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/client/src/containers/Alerts/Bills/BillDeleteAlert.js b/client/src/containers/Alerts/Bills/BillDeleteAlert.js index 7b41e4762..38f7bf636 100644 --- a/client/src/containers/Alerts/Bills/BillDeleteAlert.js +++ b/client/src/containers/Alerts/Bills/BillDeleteAlert.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 { handleDeleteErrors } from 'containers/Purchases/Bills/BillForm/utils'; import { useDeleteBill } from 'hooks/query'; @@ -23,8 +24,10 @@ function BillDeleteAlert({ // #withAlertActions closeAlert, + + // #withDrawerActions + closeDrawer, }) { - const { isLoading, mutateAsync: deleteBillMutate } = useDeleteBill(); // Handle cancel Bill @@ -40,6 +43,8 @@ function BillDeleteAlert({ message: intl.get('the_bill_has_been_deleted_successfully'), intent: Intent.SUCCESS, }); + + closeDrawer('bill-drawer'); }) .catch( ({ @@ -76,4 +81,5 @@ function BillDeleteAlert({ export default compose( withAlertStoreConnect(), withAlertActions, + withDrawerActions, )(BillDeleteAlert); diff --git a/client/src/containers/Drawers/BillDrawer/BillDetailActionsBar.js b/client/src/containers/Drawers/BillDrawer/BillDetailActionsBar.js index e67562ccf..78947d9fb 100644 --- a/client/src/containers/Drawers/BillDrawer/BillDetailActionsBar.js +++ b/client/src/containers/Drawers/BillDrawer/BillDetailActionsBar.js @@ -36,16 +36,13 @@ function BillDetailActionsBar({ // Handle edit bill. const onEditBill = () => { - return billId - ? (history.push(`/bills/${billId}/edit`), closeDrawer('bill-drawer')) - : null; + history.push(`/bills/${billId}/edit`); + closeDrawer('bill-drawer'); }; // Handle delete bill. const onDeleteBill = () => { - return billId - ? (openAlert('bill-delete', { billId }), closeDrawer('bill-drawer')) - : null; + openAlert('bill-delete', { billId }); }; return (