2018-04-11 16:21:54 +02:00
|
|
|
import React, { Component } from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
|
|
|
export default class AmountMaxButton extends Component {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
balance: PropTypes.string,
|
2018-04-27 02:38:14 +02:00
|
|
|
gasTotal: PropTypes.string,
|
|
|
|
maxModeOn: PropTypes.bool,
|
2018-04-11 16:21:54 +02:00
|
|
|
selectedToken: PropTypes.object,
|
|
|
|
setAmountToMax: PropTypes.func,
|
|
|
|
setMaxModeTo: PropTypes.func,
|
2018-04-27 02:38:14 +02:00
|
|
|
tokenBalance: PropTypes.string,
|
2018-04-11 16:21:54 +02:00
|
|
|
};
|
|
|
|
|
2018-07-02 04:09:28 +02:00
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
|
|
|
};
|
|
|
|
|
2018-04-30 18:03:49 +02:00
|
|
|
setMaxAmount () {
|
2018-04-11 16:21:54 +02:00
|
|
|
const {
|
|
|
|
balance,
|
|
|
|
gasTotal,
|
2018-04-27 02:38:14 +02:00
|
|
|
selectedToken,
|
2018-04-11 16:21:54 +02:00
|
|
|
setAmountToMax,
|
2018-04-27 02:38:14 +02:00
|
|
|
tokenBalance,
|
2018-04-11 16:21:54 +02:00
|
|
|
} = this.props
|
|
|
|
|
|
|
|
setAmountToMax({
|
2018-04-27 02:38:14 +02:00
|
|
|
balance,
|
2018-04-11 16:21:54 +02:00
|
|
|
gasTotal,
|
2018-04-27 02:38:14 +02:00
|
|
|
selectedToken,
|
|
|
|
tokenBalance,
|
2018-04-11 16:21:54 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
2018-04-26 18:38:38 +02:00
|
|
|
const { setMaxModeTo, maxModeOn } = this.props
|
2018-04-11 16:21:54 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
2018-04-27 02:38:14 +02:00
|
|
|
className="send-v2__amount-max"
|
2018-04-11 16:21:54 +02:00
|
|
|
onClick={(event) => {
|
|
|
|
event.preventDefault()
|
|
|
|
setMaxModeTo(true)
|
2018-04-30 18:03:49 +02:00
|
|
|
this.setMaxAmount()
|
2018-04-11 16:21:54 +02:00
|
|
|
}}
|
|
|
|
>
|
2018-04-26 18:38:38 +02:00
|
|
|
{!maxModeOn ? this.context.t('max') : ''}
|
2018-04-11 16:21:54 +02:00
|
|
|
</div>
|
2018-04-27 02:38:14 +02:00
|
|
|
)
|
2018-04-11 16:21:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|