2018-09-17 19:34:29 +02:00
|
|
|
import React, { PureComponent } from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import Modal from '../../modal'
|
|
|
|
import CancelTransactionGasFee from './cancel-transaction-gas-fee'
|
|
|
|
import { SUBMITTED_STATUS } from '../../../constants/transactions'
|
|
|
|
|
|
|
|
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,
|
2018-09-21 04:35:45 +02:00
|
|
|
newGasFee: PropTypes.string,
|
2018-09-17 19:34:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
componentDidUpdate () {
|
|
|
|
const { transactionStatus, showTransactionConfirmedModal } = this.props
|
|
|
|
|
|
|
|
if (transactionStatus !== SUBMITTED_STATUS) {
|
|
|
|
showTransactionConfirmedModal()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
handleSubmit = async () => {
|
|
|
|
const { createCancelTransaction, hideModal } = this.props
|
|
|
|
|
|
|
|
await createCancelTransaction()
|
|
|
|
hideModal()
|
|
|
|
}
|
|
|
|
|
|
|
|
handleCancel = () => {
|
|
|
|
this.props.hideModal()
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { t } = this.context
|
2018-09-21 04:35:45 +02:00
|
|
|
const { newGasFee } = this.props
|
2018-09-17 19:34:29 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Modal
|
|
|
|
headerText={t('attemptToCancel')}
|
2018-09-21 04:35:45 +02:00
|
|
|
onClose={this.handleCancel}
|
2018-09-17 19:34:29 +02:00
|
|
|
onSubmit={this.handleSubmit}
|
|
|
|
onCancel={this.handleCancel}
|
|
|
|
submitText={t('yesLetsTry')}
|
|
|
|
cancelText={t('nevermind')}
|
|
|
|
submitType="secondary"
|
|
|
|
>
|
|
|
|
<div>
|
|
|
|
<div className="cancel-transaction__title">
|
|
|
|
{ t('cancellationGasFee') }
|
|
|
|
</div>
|
2018-09-19 23:30:52 +02:00
|
|
|
<div className="cancel-transaction__cancel-transaction-gas-fee-container">
|
|
|
|
<CancelTransactionGasFee value={newGasFee} />
|
|
|
|
</div>
|
2018-09-17 19:34:29 +02:00
|
|
|
<div className="cancel-transaction__description">
|
|
|
|
{ t('attemptToCancelDescription') }
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Modal>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|