From 8e262c79f5216cbe2947a18f97d09104474b823b Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Sun, 12 Sep 2021 15:47:03 +0200 Subject: [PATCH] BIG-30: fix close drawer when delete sale invoice. --- .../Alerts/Invoices/InvoiceDeleteAlert.js | 21 ++++++++++++++----- .../InvoiceDetailActionsBar.js | 1 - 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/client/src/containers/Alerts/Invoices/InvoiceDeleteAlert.js b/client/src/containers/Alerts/Invoices/InvoiceDeleteAlert.js index 241737c22..2d12b3080 100644 --- a/client/src/containers/Alerts/Invoices/InvoiceDeleteAlert.js +++ b/client/src/containers/Alerts/Invoices/InvoiceDeleteAlert.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'; 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); diff --git a/client/src/containers/Drawers/InvoiceDetailDrawer/InvoiceDetailActionsBar.js b/client/src/containers/Drawers/InvoiceDetailDrawer/InvoiceDetailActionsBar.js index 558db7592..c0c37b870 100644 --- a/client/src/containers/Drawers/InvoiceDetailDrawer/InvoiceDetailActionsBar.js +++ b/client/src/containers/Drawers/InvoiceDetailDrawer/InvoiceDetailActionsBar.js @@ -47,7 +47,6 @@ function InvoiceDetailActionsBar({ // Handle delete sale invoice. const handleDeleteInvoice = () => { openAlert('invoice-delete', { invoiceId }); - closeDrawer('invoice-detail-drawer'); }; // Handle print invoices.