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.
40 lines
1.2 KiB
40 lines
1.2 KiB
4 years ago
|
import { connect } from 'react-redux';
|
||
7 years ago
|
import {
|
||
|
getGasTotal,
|
||
5 years ago
|
getSendToken,
|
||
7 years ago
|
getSendFromBalance,
|
||
7 years ago
|
getTokenBalance,
|
||
5 years ago
|
getSendMaxModeState,
|
||
5 years ago
|
getBasicGasEstimateLoadingStatus,
|
||
4 years ago
|
} from '../../../../../selectors';
|
||
|
import { updateSendAmount, setMaxModeTo } from '../../../../../store/actions';
|
||
|
import { updateSendErrors } from '../../../../../ducks/send/send.duck';
|
||
|
import { calcMaxAmount } from './amount-max-button.utils';
|
||
|
import AmountMaxButton from './amount-max-button.component';
|
||
7 years ago
|
|
||
4 years ago
|
export default connect(mapStateToProps, mapDispatchToProps)(AmountMaxButton);
|
||
7 years ago
|
|
||
4 years ago
|
function mapStateToProps(state) {
|
||
7 years ago
|
return {
|
||
7 years ago
|
balance: getSendFromBalance(state),
|
||
6 years ago
|
buttonDataLoading: getBasicGasEstimateLoadingStatus(state),
|
||
7 years ago
|
gasTotal: getGasTotal(state),
|
||
5 years ago
|
maxModeOn: getSendMaxModeState(state),
|
||
5 years ago
|
sendToken: getSendToken(state),
|
||
7 years ago
|
tokenBalance: getTokenBalance(state),
|
||
4 years ago
|
};
|
||
7 years ago
|
}
|
||
|
|
||
4 years ago
|
function mapDispatchToProps(dispatch) {
|
||
7 years ago
|
return {
|
||
5 years ago
|
setAmountToMax: (maxAmountDataObject) => {
|
||
4 years ago
|
dispatch(updateSendErrors({ amount: null }));
|
||
|
dispatch(updateSendAmount(calcMaxAmount(maxAmountDataObject)));
|
||
7 years ago
|
},
|
||
6 years ago
|
clearMaxAmount: () => {
|
||
4 years ago
|
dispatch(updateSendAmount('0'));
|
||
6 years ago
|
},
|
||
5 years ago
|
setMaxModeTo: (bool) => dispatch(setMaxModeTo(bool)),
|
||
4 years ago
|
};
|
||
7 years ago
|
}
|