import React from 'react'; import { FormattedMessage as T, FormattedHTMLMessage, useIntl, } from 'react-intl'; import { Intent, Alert } from '@blueprintjs/core'; import { useDeletePaymentReceive } from 'hooks/query'; import { AppToaster } from 'components'; import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import withAlertActions from 'containers/Alert/withAlertActions'; import { compose } from 'utils'; /** * Payment receive delete alert. */ function PaymentReceiveDeleteAlert({ name, // #withAlertStoreConnect isOpen, payload: { paymentReceiveId }, // #withAlertActions closeAlert, }) { const { formatMessage } = useIntl(); const { mutateAsync: deletePaymentReceiveMutate, isLoading, } = useDeletePaymentReceive(); // Handle cancel payment Receive. const handleCancelDeleteAlert = () => { closeAlert(name); }; // Handle confirm delete payment receive. const handleConfirmPaymentReceiveDelete = () => { deletePaymentReceiveMutate(paymentReceiveId) .then(() => { AppToaster.show({ message: formatMessage({ id: 'the_payment_receive_has_been_deleted_successfully', }), intent: Intent.SUCCESS, }); }) .catch(() => {}) .finally(() => { closeAlert(name); }); }; return ( } confirmButtonText={} icon="trash" intent={Intent.DANGER} isOpen={isOpen} onCancel={handleCancelDeleteAlert} onConfirm={handleConfirmPaymentReceiveDelete} loading={isLoading} >

); } export default compose( withAlertStoreConnect(), withAlertActions, )(PaymentReceiveDeleteAlert);