import React from 'react';
import intl from 'react-intl-universal';
import { FormattedMessage as T } from 'components';
import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components';
import { useCancelUnlockingPartialTransactions } from 'hooks/query';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import withAlertActions from 'containers/Alert/withAlertActions';
import { compose } from 'utils';
/**
* Cancel Unlocking partial transactions alerts.
*/
function CancelUnlockingPartialTarnsactions({
name,
// #withAlertStoreConnect
isOpen,
payload: { module },
// #withAlertActions
closeAlert,
}) {
const { mutateAsync: cancelUnlockingPartial, isLoading } =
useCancelUnlockingPartialTransactions();
// Handle cancel.
const handleCancel = () => {
closeAlert(name);
};
// Handle confirm.
const handleConfirm = () => {
const values = {
module: module,
};
cancelUnlockingPartial(values)
.then(() => {
AppToaster.show({
message: intl.get(
'unlocking_partial_transactions.alert.cancel_message',
),
intent: Intent.SUCCESS,
});
})
.catch(
({
response: {
data: { errors },
},
}) => {},
)
.finally(() => {
closeAlert(name);
});
};
return (