BIG-30: fix close drawer when delete sale invoice.

This commit is contained in:
elforjani3
2021-09-12 15:47:03 +02:00
parent f1619b31e9
commit 8e262c79f5
2 changed files with 16 additions and 6 deletions

View File

@@ -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';
import { useDeleteInvoice } from 'hooks/query';
@@ -9,6 +9,7 @@ import { handleDeleteErrors } from 'containers/Sales/Invoices/InvoicesLanding/co
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import withAlertActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions';
import { compose } from 'utils';
@@ -24,8 +25,10 @@ function InvoiceDeleteAlert({
// #withAlertActions
closeAlert,
// #withDrawerActions
closeDrawer,
}) {
const { mutateAsync: deleteInvoiceMutate, isLoading } = useDeleteInvoice();
// handle cancel delete invoice alert.
@@ -41,10 +44,17 @@ function InvoiceDeleteAlert({
message: intl.get('the_invoice_has_been_deleted_successfully'),
intent: Intent.SUCCESS,
});
closeDrawer('invoice-detail-drawer');
})
.catch(({ response: { data: { errors } } }) => {
handleDeleteErrors(errors);
})
.catch(
({
response: {
data: { errors },
},
}) => {
handleDeleteErrors(errors);
},
)
.finally(() => {
closeAlert(name);
});
@@ -73,4 +83,5 @@ function InvoiceDeleteAlert({
export default compose(
withAlertStoreConnect(),
withAlertActions,
withDrawerActions,
)(InvoiceDeleteAlert);

View File

@@ -47,7 +47,6 @@ function InvoiceDetailActionsBar({
// Handle delete sale invoice.
const handleDeleteInvoice = () => {
openAlert('invoice-delete', { invoiceId });
closeDrawer('invoice-detail-drawer');
};
// Handle print invoices.