BIG-34: fix close drawer when delete accounts.

This commit is contained in:
elforjani3
2021-09-12 17:19:27 +02:00
parent d15c32cc8c
commit 3ff84b4b3c
2 changed files with 17 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import intl from 'react-intl-universal'; 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 { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
@@ -9,6 +9,7 @@ import { handleDeleteErrors } from 'containers/Accounts/utils';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import withAlertActions from 'containers/Alert/withAlertActions'; import withAlertActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions';
import { useDeleteAccount } from 'hooks/query'; import { useDeleteAccount } from 'hooks/query';
import { compose } from 'utils'; import { compose } from 'utils';
@@ -25,6 +26,9 @@ function AccountDeleteAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
// #withDrawerActions
closeDrawer,
}) { }) {
const { isLoading, mutateAsync: deleteAccount } = useDeleteAccount(); const { isLoading, mutateAsync: deleteAccount } = useDeleteAccount();
@@ -41,11 +45,18 @@ function AccountDeleteAlert({
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
closeAlert(name); closeAlert(name);
closeDrawer('account-drawer');
}) })
.catch(({ response: { data: { errors } } }) => { .catch(
handleDeleteErrors(errors); ({
closeAlert(name); response: {
}); data: { errors },
},
}) => {
handleDeleteErrors(errors);
closeAlert(name);
},
);
}; };
return ( return (
@@ -71,4 +82,5 @@ function AccountDeleteAlert({
export default compose( export default compose(
withAlertStoreConnect(), withAlertStoreConnect(),
withAlertActions, withAlertActions,
withDrawerActions,
)(AccountDeleteAlert); )(AccountDeleteAlert);

View File

@@ -12,7 +12,6 @@ import { FormattedMessage as T } from 'components';
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'; import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
import withDialogActions from 'containers/Dialog/withDialogActions'; import withDialogActions from 'containers/Dialog/withDialogActions';
import withAlertsActions from 'containers/Alert/withAlertActions'; import withAlertsActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions';
import { safeCallback } from 'utils'; import { safeCallback } from 'utils';
@@ -28,9 +27,6 @@ function AccountDrawerActionBar({
// #withAlertsDialog // #withAlertsDialog
openAlert, openAlert,
// #withDrawerActions
closeDrawer,
}) { }) {
// Account drawer context. // Account drawer context.
const { account } = useAccountDrawerContext(); const { account } = useAccountDrawerContext();
@@ -52,7 +48,6 @@ function AccountDrawerActionBar({
// Handle delete action account. // Handle delete action account.
const onDeleteAccount = () => { const onDeleteAccount = () => {
openAlert('account-delete', { accountId: account.id }); openAlert('account-delete', { accountId: account.id });
closeDrawer('account-drawer');
}; };
return ( return (
@@ -85,5 +80,4 @@ function AccountDrawerActionBar({
export default compose( export default compose(
withDialogActions, withDialogActions,
withAlertsActions, withAlertsActions,
withDrawerActions,
)(AccountDrawerActionBar); )(AccountDrawerActionBar);