1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-24 12:23:39 +02:00
metamask-extension/ui/app/components/send_/send-content/send-amount-row/amount-max-button/amount-max-button.component.js

55 lines
1.0 KiB
JavaScript
Raw Normal View History

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,
gasTotal: PropTypes.string,
maxModeOn: PropTypes.bool,
2018-04-11 16:21:54 +02:00
selectedToken: PropTypes.object,
setAmountToMax: PropTypes.func,
setMaxModeTo: PropTypes.func,
tokenBalance: PropTypes.string,
2018-04-11 16:21:54 +02:00
};
2018-04-30 18:03:49 +02:00
setMaxAmount () {
2018-04-11 16:21:54 +02:00
const {
balance,
gasTotal,
selectedToken,
2018-04-11 16:21:54 +02:00
setAmountToMax,
tokenBalance,
2018-04-11 16:21:54 +02:00
} = this.props
setAmountToMax({
balance,
2018-04-11 16:21:54 +02:00
gasTotal,
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
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-11 16:21:54 +02:00
}
}
AmountMaxButton.contextTypes = {
t: PropTypes.func,
}