1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-05 07:24:56 +01:00
metamask-extension/ui/components/app/modals/cancel-transaction/cancel-transaction.component.js

76 lines
2.0 KiB
JavaScript
Raw Normal View History

import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import Modal from '../../modal';
import { TRANSACTION_STATUSES } from '../../../../../shared/constants/transaction';
import CancelTransactionGasFee from './cancel-transaction-gas-fee';
export default class CancelTransaction extends PureComponent {
static contextTypes = {
t: PropTypes.func,
};
static propTypes = {
createCancelTransaction: PropTypes.func,
hideModal: PropTypes.func,
showTransactionConfirmedModal: PropTypes.func,
transactionStatus: PropTypes.string,
newGasFee: PropTypes.string,
};
state = {
busy: false,
};
2020-11-03 00:41:28 +01:00
componentDidUpdate() {
const { transactionStatus, showTransactionConfirmedModal } = this.props;
if (transactionStatus !== TRANSACTION_STATUSES.SUBMITTED) {
showTransactionConfirmedModal();
}
}
handleSubmit = async () => {
const { createCancelTransaction, hideModal } = this.props;
this.setState({ busy: true });
await createCancelTransaction();
this.setState({ busy: false }, () => hideModal());
};
handleCancel = () => {
this.props.hideModal();
};
2020-11-03 00:41:28 +01:00
render() {
const { t } = this.context;
const { newGasFee } = this.props;
const { busy } = this.state;
return (
<Modal
headerText={t('attemptToCancel')}
onClose={this.handleCancel}
onSubmit={this.handleSubmit}
onCancel={this.handleCancel}
submitText={t('yesLetsTry')}
cancelText={t('nevermind')}
submitType="secondary"
submitDisabled={busy}
>
<div>
<div className="cancel-transaction__title">
2020-11-03 00:41:28 +01:00
{t('cancellationGasFee')}
</div>
2018-09-19 23:30:52 +02:00
<div className="cancel-transaction__cancel-transaction-gas-fee-container">
<CancelTransactionGasFee value={newGasFee} />
</div>
<div className="cancel-transaction__description">
2020-11-03 00:41:28 +01:00
{t('attemptToCancelDescription')}
</div>
</div>
</Modal>
);
}
}