disable Send button when tip amount <= 0 or tip amount > balance

This commit is contained in:
Travis Eden 2018-05-14 12:19:07 -04:00
parent f001181907
commit 82e6635460
2 changed files with 6 additions and 2 deletions

View file

@ -4,6 +4,7 @@ import {
makeSelectTitleForUri, makeSelectTitleForUri,
makeSelectClaimForUri, makeSelectClaimForUri,
selectIsSendingSupport, selectIsSendingSupport,
selectBalance,
} from 'lbry-redux'; } from 'lbry-redux';
import WalletSendTip from './view'; import WalletSendTip from './view';
@ -11,6 +12,7 @@ const select = (state, props) => ({
isPending: selectIsSendingSupport(state), isPending: selectIsSendingSupport(state),
title: makeSelectTitleForUri(props.uri)(state), title: makeSelectTitleForUri(props.uri)(state),
claim: makeSelectClaimForUri(props.uri)(state), claim: makeSelectClaimForUri(props.uri)(state),
balance: selectBalance(state),
}); });
const perform = dispatch => ({ const perform = dispatch => ({

View file

@ -14,6 +14,7 @@ type Props = {
sendSupport: (number, string, string) => void, sendSupport: (number, string, string) => void,
onCancel: () => void, onCancel: () => void,
sendTipCallback?: () => void, sendTipCallback?: () => void,
balance: number,
}; };
type State = { type State = {
@ -51,7 +52,8 @@ class WalletSendTip extends React.PureComponent<Props, State> {
} }
render() { render() {
const { title, errorMessage, isPending, uri, onCancel } = this.props; const { title, errorMessage, isPending, uri, onCancel, balance } = this.props;
const { amount } = this.state;
return ( return (
<div> <div>
@ -82,7 +84,7 @@ class WalletSendTip extends React.PureComponent<Props, State> {
<Button <Button
button="primary" button="primary"
label={__('Send')} label={__('Send')}
disabled={isPending} disabled={isPending || amount <= 0 || amount > balance}
onClick={this.handleSendButtonClicked} onClick={this.handleSendButtonClicked}
/> />
<Button button="alt" label={__('Cancel')} onClick={onCancel} navigateParams={{ uri }} /> <Button button="alt" label={__('Cancel')} onClick={onCancel} navigateParams={{ uri }} />