BIG-32: fix close drawer when delete sale receipt.

This commit is contained in:
elforjani3
2021-09-12 15:48:11 +02:00
parent 823bbd94b7
commit 0eccd4da8e
2 changed files with 11 additions and 15 deletions

View File

@@ -1,14 +1,14 @@
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 { queryCache } from 'react-query';
import { useDeleteReceipt } from 'hooks/query'; import { useDeleteReceipt } from 'hooks/query';
import { AppToaster } from 'components'; 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 { compose } from 'utils'; import { compose } from 'utils';
@@ -24,12 +24,11 @@ function NameDeleteAlert({
// #withAlertActions // #withAlertActions
closeAlert, closeAlert,
// #withDrawerActions
closeDrawer,
}) { }) {
const { mutateAsync: deleteReceiptMutate, isLoading } = useDeleteReceipt();
const {
mutateAsync: deleteReceiptMutate,
isLoading
} = useDeleteReceipt();
// Handle cancel delete alert. // Handle cancel delete alert.
const handleCancelDeleteAlert = () => { const handleCancelDeleteAlert = () => {
@@ -44,6 +43,7 @@ function NameDeleteAlert({
message: intl.get('the_receipt_has_been_deleted_successfully'), message: intl.get('the_receipt_has_been_deleted_successfully'),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
closeDrawer('receipt-detail-drawer');
}) })
.catch(() => {}) .catch(() => {})
.finally(() => { .finally(() => {
@@ -74,4 +74,5 @@ function NameDeleteAlert({
export default compose( export default compose(
withAlertStoreConnect(), withAlertStoreConnect(),
withAlertActions, withAlertActions,
withDrawerActions
)(NameDeleteAlert); )(NameDeleteAlert);

View File

@@ -34,18 +34,13 @@ function ReceiptDetailActionBar({
// Handle edit sale receipt. // Handle edit sale receipt.
const onEditReceipt = () => { const onEditReceipt = () => {
return receiptId history.push(`/receipts/${receiptId}/edit`);
? (history.push(`/receipts/${receiptId}/edit`), closeDrawer('receipt-detail-drawer');
closeDrawer('receipt-detail-drawer'))
: null;
}; };
// Handle delete sale receipt. // Handle delete sale receipt.
const onDeleteReceipt = () => { const onDeleteReceipt = () => {
return receiptId openAlert('receipt-delete', { receiptId });
? (openAlert('receipt-delete', { receiptId }),
closeDrawer('receipt-detail-drawer'))
: null;
}; };
// Handle print receipt. // Handle print receipt.
const onPrintReceipt = () => { const onPrintReceipt = () => {