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.
55 lines
1.0 KiB
55 lines
1.0 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,
|
||
7 years ago
|
};
|
||
|
|
||
7 years ago
|
static contextTypes = {
|
||
|
t: PropTypes.func,
|
||
|
};
|
||
|
|
||
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
|
})
|
||
|
}
|
||
|
|
||
|
render () {
|
||
7 years ago
|
const { setMaxModeTo, maxModeOn } = this.props
|
||
7 years ago
|
|
||
|
return (
|
||
|
<div
|
||
7 years ago
|
className="send-v2__amount-max"
|
||
7 years ago
|
onClick={(event) => {
|
||
|
event.preventDefault()
|
||
|
setMaxModeTo(true)
|
||
7 years ago
|
this.setMaxAmount()
|
||
7 years ago
|
}}
|
||
|
>
|
||
7 years ago
|
{!maxModeOn ? this.context.t('max') : ''}
|
||
7 years ago
|
</div>
|
||
7 years ago
|
)
|
||
7 years ago
|
}
|
||
|
|
||
|
}
|