Browse Source

display max avail balance on send validation err

v0.25
pbca26 7 years ago
parent
commit
dfac634327
  1. 14
      react/src/actions/actions/interest.js
  2. 24
      react/src/components/dashboard/sendCoin/sendCoin.js
  3. 10
      react/src/components/dashboard/sendCoin/sendCoin.render.js
  4. 2
      react/src/translate/en.js

14
react/src/actions/actions/interest.js

@ -35,6 +35,20 @@ export function getListUnspent(coin) {
})
.then(response => response.json())
.then(json => {
if (json &&
json.result &&
json.result.length) {
let _spendable = [];
for (let i = 0; i < json.result.length; i++) {
if (json.result[i].spendable) {
_spendable.push(json.result[i]);
}
}
json.result = _spendable;
}
resolve(json.result ? json.result : json);
})
});

24
react/src/components/dashboard/sendCoin/sendCoin.js

@ -36,7 +36,7 @@ class SendCoin extends React.Component {
fee: 0,
addressSelectorOpen: false,
renderAddressDropdown: true,
substractFee: false,
subtractFee: false,
lastSendToResponse: null,
coin: null,
spvVerificationWarning: false,
@ -51,7 +51,7 @@ class SendCoin extends React.Component {
this.renderOPIDListCheck = this.renderOPIDListCheck.bind(this);
this.SendFormRender = _SendFormRender.bind(this);
this.isTransparentTx = this.isTransparentTx.bind(this);
this.toggleSubstractFee = this.toggleSubstractFee.bind(this);
this.toggleSubtractFee = this.toggleSubtractFee.bind(this);
this.isFullySynced = this.isFullySynced.bind(this);
}
@ -59,9 +59,9 @@ class SendCoin extends React.Component {
return _SendFormRender.call(this);
}
toggleSubstractFee() {
toggleSubtractFee() {
this.setState({
substractFee: !this.state.substractFee,
subtractFee: !this.state.subtractFee,
});
}
@ -147,7 +147,7 @@ class SendCoin extends React.Component {
fee: 0,
addressSelectorOpen: false,
renderAddressDropdown: true,
substractFee: false,
subtractFee: false,
lastSendToResponse: null,
};
let updatedState;
@ -365,7 +365,7 @@ class SendCoin extends React.Component {
fee: 0,
addressSelectorOpen: false,
renderAddressDropdown: true,
substractFee: false,
subtractFee: false,
spvVerificationWarning: false,
spvPreflightSendInProgress: false,
});
@ -460,10 +460,10 @@ class SendCoin extends React.Component {
const _amountSats = this.state.amount * 100000000;
const _balanceSats = this.props.ActiveCoin.balance.balanceSats;
if (_amountSats > _balanceSats) {
if (Number(_amountSats) + 10000 > _balanceSats) {
Store.dispatch(
triggerToaster(
translate('SEND.INSUFFICIENT_FUNDS'),
`${translate('SEND.INSUFFICIENT_FUNDS')} max available balance is ${(0.00000001 * (_balanceSats - 10000)).toFixed(8)} ${this.props.ActiveCoin.coin}`,
translate('TOASTR.WALLET_NOTIFICATION'),
'error'
)
@ -500,18 +500,18 @@ class SendCoin extends React.Component {
this.state.sendTo.length === 34 &&
this.props.ActiveCoin.balance &&
this.props.ActiveCoin.balance.transparent &&
Number(this.state.amount) > Number(this.props.ActiveCoin.balance.transparent)) ||
Number(Number(this.state.amount) + 0.0001) > Number(this.props.ActiveCoin.balance.transparent)) ||
(this.state.addressType === 'public' &&
this.state.sendTo &&
this.state.sendTo.length > 34 &&
Number(this.state.amount) > Number(this.state.sendFromAmount)) ||
Number(Number(this.state.amount) + 0.0001) > Number(this.state.sendFromAmount)) ||
(this.state.addressType === 'private' &&
this.state.sendTo &&
this.state.sendTo.length >= 34 &&
Number(this.state.amount) > Number(this.state.sendFromAmount))) {
Number(Number(this.state.amount) + 0.0001) > Number(this.state.sendFromAmount))) {
Store.dispatch(
triggerToaster(
translate('SEND.INSUFFICIENT_FUNDS'),
`${translate('SEND.INSUFFICIENT_FUNDS')} max available balance is ${Number(this.state.sendFromAmount || this.props.ActiveCoin.balance.transparent)} ${this.props.ActiveCoin.coin}`,
translate('TOASTR.WALLET_NOTIFICATION'),
'error'
)

10
react/src/components/dashboard/sendCoin/sendCoin.render.js

@ -85,15 +85,15 @@ export const _SendFormRender = function() {
<label className="switch">
<input
type="checkbox"
checked={ this.state.substractFee } />
checked={ this.state.subtractFee } />
<div
className="slider"
onClick={ () => this.toggleSubstractFee() }></div>
onClick={ () => this.toggleSubtractFee() }></div>
</label>
<div
className="toggle-label"
onClick={ () => this.toggleSubstractFee() }>
{ translate('DASHBOARD.SUBSTRACT_FEE') }
onClick={ () => this.toggleSubtractFee() }>
{ translate('DASHBOARD.SUBTRACT_FEE') }
</div>
</span>
</div>
@ -206,7 +206,7 @@ export const SendRender = function() {
<div className="col-lg-6 col-sm-6 col-xs-6">
{ this.state.amount } { this.props.ActiveCoin.coin }
</div>
<div className={ this.state.substractFee ? 'col-lg-6 col-sm-6 col-xs-12 padding-top-10 bold' : 'hide' }>{ translate('DASHBOARD.SUBSTRACT_FEE') }</div>
<div className={ this.state.subtractFee ? 'col-lg-6 col-sm-6 col-xs-12 padding-top-10 bold' : 'hide' }>{ translate('DASHBOARD.SUBTRACT_FEE') }</div>
</div>
{ this.state.sendFrom &&

2
react/src/translate/en.js

@ -440,7 +440,7 @@ export const _lang = {
'SEND_FEE_REQ': 'Make sure you have fee entered. Default value is',
'SEND_TOTAL_REQ': 'Make sure you have both amount and fee entered to calculate final total.',
'SEND_TX_PROGRESS': 'The transaction submitted is processing. Once processed the transaction details will be displayed here.',
'SUBSTRACT_FEE': 'Subtract fee from amount',
'SUBTRACT_FEE': 'Subtract fee from amount',
'UNKNOWN': 'Unknown',
'IN': 'IN',
'OUT': 'OUT',

Loading…
Cancel
Save