BIG-35: fix close drawer when delete expense.

This commit is contained in:
elforjani3
2021-09-12 17:07:36 +02:00
parent 39bfdd1ce5
commit 4711ab34d4
2 changed files with 10 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ import { AppToaster } from 'components';
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 { useDeleteExpense } from 'hooks/query'; import { useDeleteExpense } from 'hooks/query';
import { compose } from 'utils'; import { compose } from 'utils';
@@ -20,6 +21,9 @@ function ExpenseDeleteAlert({
// #withAlertStoreConnect // #withAlertStoreConnect
isOpen, isOpen,
payload: { expenseId }, payload: { expenseId },
// #withDrawerActions
closeDrawer,
}) { }) {
const { mutateAsync: deleteExpenseMutate, isLoading } = useDeleteExpense(); const { mutateAsync: deleteExpenseMutate, isLoading } = useDeleteExpense();
@@ -38,7 +42,7 @@ function ExpenseDeleteAlert({
}), }),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
closeAlert('expense-delete'); closeDrawer('expense-drawer');
}) })
.catch( .catch(
({ ({
@@ -57,7 +61,10 @@ function ExpenseDeleteAlert({
}); });
} }
}, },
); )
.finally(() => {
closeAlert('expense-delete');
});
}; };
return ( return (
@@ -81,4 +88,5 @@ function ExpenseDeleteAlert({
export default compose( export default compose(
withAlertStoreConnect(), withAlertStoreConnect(),
withAlertActions, withAlertActions,
withDrawerActions,
)(ExpenseDeleteAlert); )(ExpenseDeleteAlert);

View File

@@ -39,7 +39,6 @@ function ExpenseDrawerActionBar({
// Handle the expense delete action. // Handle the expense delete action.
const handleDeleteExpense = () => { const handleDeleteExpense = () => {
openAlert('expense-delete', { expenseId: expense.id }); openAlert('expense-delete', { expenseId: expense.id });
closeDrawer('expense-drawer');
}; };
return ( return (