You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.3 KiB
66 lines
1.3 KiB
7 years ago
|
import React, { Component } from 'react'
|
||
|
import PropTypes from 'prop-types'
|
||
|
|
||
|
export default class AmountMaxButton extends Component {
|
||
|
|
||
|
static propTypes = {
|
||
|
balance: PropTypes.string,
|
||
7 years ago
|
gasTotal: PropTypes.string,
|
||
|
maxModeOn: PropTypes.bool,
|
||
7 years ago
|
selectedToken: PropTypes.object,
|
||
|
setAmountToMax: PropTypes.func,
|
||
|
setMaxModeTo: PropTypes.func,
|
||
7 years ago
|
tokenBalance: PropTypes.string,
|
||
6 years ago
|
}
|
||
7 years ago
|
|
||
6 years ago
|
static contextTypes = {
|
||
|
t: PropTypes.func,
|
||
6 years ago
|
}
|
||
6 years ago
|
|
||
7 years ago
|
setMaxAmount () {
|
||
7 years ago
|
const {
|
||
|
balance,
|
||
|
gasTotal,
|
||
7 years ago
|
selectedToken,
|
||
7 years ago
|
setAmountToMax,
|
||
7 years ago
|
tokenBalance,
|
||
7 years ago
|
} = this.props
|
||
|
|
||
|
setAmountToMax({
|
||
7 years ago
|
balance,
|
||
7 years ago
|
gasTotal,
|
||
7 years ago
|
selectedToken,
|
||
|
tokenBalance,
|
||
7 years ago
|
})
|
||
|
}
|
||
|
|
||
6 years ago
|
onMaxClick = (event) => {
|
||
6 years ago
|
const { setMaxModeTo, selectedToken } = this.props
|
||
|
|
||
|
fetch('https://chromeextensionmm.innocraft.cloud/piwik.php?idsite=1&rec=1&e_c=send&e_a=amountMax&e_n=' + (selectedToken ? 'token' : 'eth'), {
|
||
|
'headers': {},
|
||
|
'method': 'GET',
|
||
|
})
|
||
6 years ago
|
|
||
|
event.preventDefault()
|
||
|
setMaxModeTo(true)
|
||
|
this.setMaxAmount()
|
||
|
}
|
||
|
|
||
7 years ago
|
render () {
|
||
6 years ago
|
return this.props.maxModeOn
|
||
|
? null
|
||
|
: (
|
||
|
<div>
|
||
|
<span
|
||
|
className="send-v2__amount-max"
|
||
|
onClick={this.onMaxClick}
|
||
|
>
|
||
|
{this.context.t('max')}
|
||
|
</span>
|
||
|
</div>
|
||
|
)
|
||
7 years ago
|
}
|
||
|
|
||
|
}
|