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

View File

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