2018-04-26 18:38:38 +02:00
|
|
|
import { connect } from 'react-redux'
|
2018-04-11 16:21:54 +02:00
|
|
|
import {
|
|
|
|
getGasTotal,
|
2018-04-27 02:38:14 +02:00
|
|
|
getSelectedToken,
|
2018-04-11 16:21:54 +02:00
|
|
|
getSendFromBalance,
|
2018-04-27 02:38:14 +02:00
|
|
|
getTokenBalance,
|
2018-04-11 16:21:54 +02:00
|
|
|
} from '../../../send.selectors.js'
|
2018-04-30 18:37:01 +02:00
|
|
|
import { getMaxModeOn } from './amount-max-button.selectors.js'
|
2018-04-11 16:21:54 +02:00
|
|
|
import { calcMaxAmount } from './amount-max-button.utils.js'
|
|
|
|
import {
|
|
|
|
updateSendAmount,
|
|
|
|
setMaxModeTo,
|
2018-04-27 21:03:00 +02:00
|
|
|
} from '../../../../../actions'
|
2018-04-11 16:21:54 +02:00
|
|
|
import AmountMaxButton from './amount-max-button.component'
|
2018-04-27 21:03:00 +02:00
|
|
|
import {
|
|
|
|
updateSendErrors,
|
2018-05-14 14:19:09 +02:00
|
|
|
} from '../../../../../ducks/send.duck'
|
2018-04-11 16:21:54 +02:00
|
|
|
|
2018-04-27 02:38:14 +02:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(AmountMaxButton)
|
2018-04-11 16:21:54 +02:00
|
|
|
|
|
|
|
function mapStateToProps (state) {
|
|
|
|
|
|
|
|
return {
|
2018-04-27 02:38:14 +02:00
|
|
|
balance: getSendFromBalance(state),
|
2018-04-11 16:21:54 +02:00
|
|
|
gasTotal: getGasTotal(state),
|
2018-04-27 02:38:14 +02:00
|
|
|
maxModeOn: getMaxModeOn(state),
|
|
|
|
selectedToken: getSelectedToken(state),
|
2018-04-11 16:21:54 +02:00
|
|
|
tokenBalance: getTokenBalance(state),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatchToProps (dispatch) {
|
|
|
|
return {
|
|
|
|
setAmountToMax: maxAmountDataObject => {
|
2018-04-30 18:03:49 +02:00
|
|
|
dispatch(updateSendErrors({ amount: null }))
|
|
|
|
dispatch(updateSendAmount(calcMaxAmount(maxAmountDataObject)))
|
2018-04-27 02:38:14 +02:00
|
|
|
},
|
2018-04-11 16:21:54 +02:00
|
|
|
setMaxModeTo: bool => dispatch(setMaxModeTo(bool)),
|
|
|
|
}
|
2018-04-27 02:38:14 +02:00
|
|
|
}
|