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 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);

View File

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