fix(send): only shows balance tooltip if from address is valid
This commit is contained in:
parent
8bcd08b915
commit
52b496c476
|
@ -361,7 +361,11 @@ class Component extends PureComponent<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTooltipVisibility = ({ balance, amount }: { balance: number, amount: number }) => {
|
updateTooltipVisibility = ({ balance, amount }: { balance: number, amount: number }) => {
|
||||||
this.setState({ showBalanceTooltip: new BigNumber(amount).gt(balance) });
|
const { from, to } = this.state;
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
showBalanceTooltip: !from || !to ? false : new BigNumber(amount).gt(balance),
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
getAmountWithFee = () => {
|
getAmountWithFee = () => {
|
||||||
|
@ -379,11 +383,15 @@ class Component extends PureComponent<Props, State> {
|
||||||
const { amount } = this.state;
|
const { amount } = this.state;
|
||||||
|
|
||||||
if (field === 'to') {
|
if (field === 'to') {
|
||||||
this.setState(() => ({ [field]: value }), () => validateAddress({ address: String(value) }));
|
|
||||||
} else if (field === 'amount') {
|
|
||||||
this.setState(
|
this.setState(
|
||||||
() => ({ [field]: value }),
|
() => ({ [field]: value }),
|
||||||
() => this.updateTooltipVisibility({ balance, amount: new BigNumber(value).toNumber() }),
|
() => {
|
||||||
|
validateAddress({ address: String(value) });
|
||||||
|
this.updateTooltipVisibility({
|
||||||
|
balance,
|
||||||
|
amount: new BigNumber(amount).toNumber(),
|
||||||
|
});
|
||||||
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (field === 'from') getAddressBalance({ address: String(value) });
|
if (field === 'from') getAddressBalance({ address: String(value) });
|
||||||
|
@ -392,6 +400,10 @@ class Component extends PureComponent<Props, State> {
|
||||||
() => ({ [field]: value }),
|
() => ({ [field]: value }),
|
||||||
() => {
|
() => {
|
||||||
if (field === 'fee') this.handleChange('amount')(amount);
|
if (field === 'fee') this.handleChange('amount')(amount);
|
||||||
|
this.updateTooltipVisibility({
|
||||||
|
balance,
|
||||||
|
amount: new BigNumber(field === 'amount' ? value : amount).toNumber(),
|
||||||
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -461,7 +473,6 @@ class Component extends PureComponent<Props, State> {
|
||||||
const feeValue = new BigNumber(fee);
|
const feeValue = new BigNumber(fee);
|
||||||
|
|
||||||
if (feeValue.isEqualTo(FEES.LOW)) return `Low ZEC ${feeValue.toString()}`;
|
if (feeValue.isEqualTo(FEES.LOW)) return `Low ZEC ${feeValue.toString()}`;
|
||||||
// eslint-disable-next-line max-len
|
|
||||||
if (feeValue.isEqualTo(FEES.MEDIUM)) return `Medium ZEC ${feeValue.toString()}`;
|
if (feeValue.isEqualTo(FEES.MEDIUM)) return `Medium ZEC ${feeValue.toString()}`;
|
||||||
if (feeValue.isEqualTo(FEES.HIGH)) return `High ZEC ${feeValue.toString()}`;
|
if (feeValue.isEqualTo(FEES.HIGH)) return `High ZEC ${feeValue.toString()}`;
|
||||||
|
|
||||||
|
@ -474,12 +485,12 @@ class Component extends PureComponent<Props, State> {
|
||||||
return isToAddressValid ? (
|
return isToAddressValid ? (
|
||||||
<ValidateWrapper alignItems='center'>
|
<ValidateWrapper alignItems='center'>
|
||||||
<ValidateStatusIcon src={ValidIcon} />
|
<ValidateStatusIcon src={ValidIcon} />
|
||||||
<ValidateItemLabel value='VALID' color={theme.colors.transactionReceived} />
|
<ValidateItemLabel value='VALID' color={theme.colors.transactionReceived(this.props)} />
|
||||||
</ValidateWrapper>
|
</ValidateWrapper>
|
||||||
) : (
|
) : (
|
||||||
<ValidateWrapper alignItems='center'>
|
<ValidateWrapper alignItems='center'>
|
||||||
<ValidateStatusIcon src={InvalidIcon} />
|
<ValidateStatusIcon src={InvalidIcon} />
|
||||||
<ValidateItemLabel value='INVALID' color={theme.colors.transactionSent} />
|
<ValidateItemLabel value='INVALID' color={theme.colors.transactionSent(this.props)} />
|
||||||
</ValidateWrapper>
|
</ValidateWrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -712,8 +723,8 @@ class Component extends PureComponent<Props, State> {
|
||||||
onChange={this.handleChange('fee')}
|
onChange={this.handleChange('fee')}
|
||||||
value={String(fee)}
|
value={String(fee)}
|
||||||
disabled={feeType !== FEES.CUSTOM}
|
disabled={feeType !== FEES.CUSTOM}
|
||||||
bgColor={theme.colors.sendAdditionalInputBg}
|
bgColor={theme.colors.sendAdditionalInputBg(this.props)}
|
||||||
color={theme.colors.sendAdditionalInputText}
|
color={theme.colors.sendAdditionalInputText(this.props)}
|
||||||
name='fee'
|
name='fee'
|
||||||
/>
|
/>
|
||||||
</ColumnComponent>
|
</ColumnComponent>
|
||||||
|
@ -721,7 +732,7 @@ class Component extends PureComponent<Props, State> {
|
||||||
<SelectComponent
|
<SelectComponent
|
||||||
placement='top'
|
placement='top'
|
||||||
value={String(feeType)}
|
value={String(feeType)}
|
||||||
bgColor={theme.colors.sendAdditionalInputBg}
|
bgColor={theme.colors.sendAdditionalInputBg(this.props)}
|
||||||
onChange={this.handleChangeFeeType}
|
onChange={this.handleChangeFeeType}
|
||||||
options={Object.keys(FEES).map(cur => ({
|
options={Object.keys(FEES).map(cur => ({
|
||||||
label: cur.toLowerCase(),
|
label: cur.toLowerCase(),
|
||||||
|
|
Loading…
Reference in New Issue