From 3ff84b4b3cd8d8419176836cecc3d08ce7c991f8 Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Sun, 12 Sep 2021 17:19:27 +0200 Subject: [PATCH] BIG-34: fix close drawer when delete accounts. --- .../containers/Alerts/AccountDeleteAlert.js | 22 ++++++++++++++----- .../AccountDrawer/AccountDrawerActionBar.js | 6 ----- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/client/src/containers/Alerts/AccountDeleteAlert.js b/client/src/containers/Alerts/AccountDeleteAlert.js index 229de8e82..e68fac261 100644 --- a/client/src/containers/Alerts/AccountDeleteAlert.js +++ b/client/src/containers/Alerts/AccountDeleteAlert.js @@ -1,6 +1,6 @@ import React from 'react'; import intl from 'react-intl-universal'; -import { FormattedMessage as T, FormattedHTMLMessage } from 'components'; +import { FormattedMessage as T, FormattedHTMLMessage } from 'components'; import { Intent, Alert } from '@blueprintjs/core'; import { AppToaster } from 'components'; @@ -9,6 +9,7 @@ import { handleDeleteErrors } from 'containers/Accounts/utils'; import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import withAlertActions from 'containers/Alert/withAlertActions'; +import withDrawerActions from 'containers/Drawer/withDrawerActions'; import { useDeleteAccount } from 'hooks/query'; import { compose } from 'utils'; @@ -25,6 +26,9 @@ function AccountDeleteAlert({ // #withAlertActions closeAlert, + + // #withDrawerActions + closeDrawer, }) { const { isLoading, mutateAsync: deleteAccount } = useDeleteAccount(); @@ -41,11 +45,18 @@ function AccountDeleteAlert({ intent: Intent.SUCCESS, }); closeAlert(name); + closeDrawer('account-drawer'); }) - .catch(({ response: { data: { errors } } }) => { - handleDeleteErrors(errors); - closeAlert(name); - }); + .catch( + ({ + response: { + data: { errors }, + }, + }) => { + handleDeleteErrors(errors); + closeAlert(name); + }, + ); }; return ( @@ -71,4 +82,5 @@ function AccountDeleteAlert({ export default compose( withAlertStoreConnect(), withAlertActions, + withDrawerActions, )(AccountDeleteAlert); diff --git a/client/src/containers/Drawers/AccountDrawer/AccountDrawerActionBar.js b/client/src/containers/Drawers/AccountDrawer/AccountDrawerActionBar.js index 37f7b6a4e..cd4f11d90 100644 --- a/client/src/containers/Drawers/AccountDrawer/AccountDrawerActionBar.js +++ b/client/src/containers/Drawers/AccountDrawer/AccountDrawerActionBar.js @@ -12,7 +12,6 @@ import { FormattedMessage as T } from 'components'; import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'; import withDialogActions from 'containers/Dialog/withDialogActions'; import withAlertsActions from 'containers/Alert/withAlertActions'; -import withDrawerActions from 'containers/Drawer/withDrawerActions'; import { safeCallback } from 'utils'; @@ -28,9 +27,6 @@ function AccountDrawerActionBar({ // #withAlertsDialog openAlert, - - // #withDrawerActions - closeDrawer, }) { // Account drawer context. const { account } = useAccountDrawerContext(); @@ -52,7 +48,6 @@ function AccountDrawerActionBar({ // Handle delete action account. const onDeleteAccount = () => { openAlert('account-delete', { accountId: account.id }); - closeDrawer('account-drawer'); }; return ( @@ -85,5 +80,4 @@ function AccountDrawerActionBar({ export default compose( withDialogActions, withAlertsActions, - withDrawerActions, )(AccountDrawerActionBar);