fix(send): fix maxAmount button

This commit is contained in:
George Lima 2019-03-18 11:15:05 -03:00
parent 32246727b5
commit fcc7f555ef
1 changed files with 10 additions and 1 deletions

View File

@ -449,6 +449,15 @@ class Component extends PureComponent<Props, State> {
return new BigNumber(amount).plus(feeValue).toNumber();
};
getMaxAmountWithoutFee = () => {
const { balance } = this.props;
const { fee } = this.state;
const max = new BigNumber(balance).minus(fee || 0);
return max.isNegative() ? 0 : max.toNumber();
};
handleChange = (field: string) => (value: string | number) => {
const { validateAddress, getAddressBalance, balance } = this.props;
const { amount } = this.state;
@ -752,7 +761,7 @@ class Component extends PureComponent<Props, State> {
<AmountInput
renderRight={() => (
<MaxAvailableAmount
onClick={() => this.handleChange('amount')(balance - (Number(fee) || 0))}
onClick={() => this.handleChange('amount')(this.getMaxAmountWithoutFee())}
disabled={!from}
>
<MaxAvailableAmountImg src={arrowUpIcon} />