diff --git a/src/renderer/component/publishForm/view.jsx b/src/renderer/component/publishForm/view.jsx index 602bedb8f..a92f7b87b 100644 --- a/src/renderer/component/publishForm/view.jsx +++ b/src/renderer/component/publishForm/view.jsx @@ -155,10 +155,14 @@ class PublishForm extends React.PureComponent { const { balance, updatePublishForm } = this.props; let bidError; - if (balance <= bid) { - bidError = __('Not enough credits'); + if (bid === 0) { + bidError = __('Deposit cannot be 0'); + } else if (balance === bid) { + bidError = __('Please decrease your deposit to account for transaction fees'); + } else if (balance < bid) { + bidError = __('Deposit cannot be higher than your balance'); } else if (bid <= MINIMUM_PUBLISH_BID) { - bidError = __('Your bid must be higher'); + bidError = __('Your deposit must be higher'); } updatePublishForm({ bid, bidError }); diff --git a/src/renderer/component/selectChannel/view.jsx b/src/renderer/component/selectChannel/view.jsx index 2c1f9ed22..01dbb8d41 100644 --- a/src/renderer/component/selectChannel/view.jsx +++ b/src/renderer/component/selectChannel/view.jsx @@ -55,11 +55,13 @@ class ChannelSection extends React.PureComponent { handleChannelChange(event: SyntheticInputEvent<*>) { const { onChannelChange } = this.props; + const { newChannelBid } = this.state; const channel = event.target.value; if (channel === CHANNEL_NEW) { this.setState({ addingChannel: true }); onChannelChange(channel); + this.handleNewChannelBidChange(newChannelBid); } else { this.setState({ addingChannel: false }); onChannelChange(channel); @@ -84,14 +86,15 @@ class ChannelSection extends React.PureComponent { }); } - handleNewChannelBidChange(event: SyntheticInputEvent<*>) { + handleNewChannelBidChange(newChannelBid: number) { const { balance } = this.props; - const newChannelBid = parseFloat(event.target.value); let newChannelBidError; - if (newChannelBid === balance) { - newChannelBidError = __('Please decrease your bid to account for transaction fees'); + if (newChannelBid === 0) { + newChannelBidError = __('Your deposit cannot be 0'); + } else if (newChannelBid === balance) { + newChannelBidError = __('Please decrease your deposit to account for transaction fees'); } else if (newChannelBid > balance) { - newChannelBidError = __('Not enough credits'); + newChannelBidError = __('Deposit cannot be higher than your balance'); } this.setState({ @@ -176,6 +179,7 @@ class ChannelSection extends React.PureComponent { label={__('Name')} type="text" prefix="@" + placeholder={__('myChannelName')} error={newChannelNameError} value={newChannelName} onChange={this.handleNewChannelNameChange} @@ -183,6 +187,7 @@ class ChannelSection extends React.PureComponent { { )} error={newChannelBidError} value={newChannelBid} - onChange={this.handleNewChannelBidChange} + onChange={event => this.handleNewChannelBidChange(parseFloat(event.target.value))} />
diff --git a/src/renderer/component/walletSend/view.jsx b/src/renderer/component/walletSend/view.jsx index 1d7942676..154eda424 100644 --- a/src/renderer/component/walletSend/view.jsx +++ b/src/renderer/component/walletSend/view.jsx @@ -65,10 +65,13 @@ class WalletSend extends React.PureComponent { value={values.amount} error={ (!!values.amount && touched.amount && errors.amount) || - (values.amount > balance && __('Not enough')) + (values.amount === balance && + __('Decrease amount to account for transaction fee')) || + (values.amount > balance && __('Not enough credits')) } /> - + + { disabled={ !values.address || !!Object.keys(errors).length || - !(parseFloat(values.amount) > 0.0) + !(parseFloat(values.amount) > 0.0) || + parseFloat(values.amount) === balance } />
diff --git a/src/renderer/component/walletSendTip/view.jsx b/src/renderer/component/walletSendTip/view.jsx index 477932eab..b6e0e37f4 100644 --- a/src/renderer/component/walletSendTip/view.jsx +++ b/src/renderer/component/walletSendTip/view.jsx @@ -9,7 +9,6 @@ type Props = { uri: string, title: string, claim: Claim, - errorMessage: string, isPending: boolean, sendSupport: (number, string, string) => void, onCancel: () => void, @@ -18,7 +17,8 @@ type Props = { }; type State = { - amount: number, + tipAmount: number, + newTipError: string, }; class WalletSendTip extends React.PureComponent { @@ -26,7 +26,8 @@ class WalletSendTip extends React.PureComponent { super(props); this.state = { - amount: 0, + tipAmount: 0, + newTipError: '', }; (this: any).handleSendButtonClicked = this.handleSendButtonClicked.bind(this); @@ -35,9 +36,9 @@ class WalletSendTip extends React.PureComponent { handleSendButtonClicked() { const { claim, uri, sendSupport, sendTipCallback } = this.props; const { claim_id: claimId } = claim; - const { amount } = this.state; + const { tipAmount } = this.state; - sendSupport(amount, claimId, uri); + sendSupport(tipAmount, claimId, uri); // ex: close modal if (sendTipCallback) { @@ -46,14 +47,24 @@ class WalletSendTip extends React.PureComponent { } handleSupportPriceChange(event: SyntheticInputEvent<*>) { + const { balance } = this.props; + const tipAmount = parseFloat(event.target.value); + let newTipError; + if (tipAmount === balance) { + newTipError = __('Please decrease your tip to account for transaction fees'); + } else if (tipAmount > balance) { + newTipError = __('Not enough credits'); + } + this.setState({ - amount: Number(event.target.value), + tipAmount, + newTipError, }); } render() { - const { title, errorMessage, isPending, uri, onCancel, balance } = this.props; - const { amount } = this.state; + const { title, isPending, uri, onCancel, balance } = this.props; + const { tipAmount, newTipError } = this.state; return (
@@ -67,7 +78,8 @@ class WalletSendTip extends React.PureComponent { label={__('Amount')} postfix={__('LBC')} className="input--price-amount" - error={errorMessage} + error={newTipError} + value={tipAmount} min="0" step="any" type="number" @@ -84,7 +96,7 @@ class WalletSendTip extends React.PureComponent {