Browse Source

hide send btn if zero balance

all-modes
pbca26 8 years ago
parent
commit
feb5f5a01a
  1. 2
      react/src/components/dashboard/walletsBalance/walletsBalance.render.js
  2. 36
      react/src/components/dashboard/walletsNav/walletsNav.js
  3. 14
      react/src/components/dashboard/walletsNav/walletsNav.render.js

2
react/src/components/dashboard/walletsBalance/walletsBalance.render.js

@ -38,7 +38,7 @@ const WalletsBalanceRender = function() {
<span
className="pull-right padding-top-10 font-size-22"
title={ Config.roundValues ? formatValue('round', this.renderBalance('transparent'), -6) : this.renderBalance('transparent') }>
{ Config.roundValues ? formatValue('round', this.renderBalance('transparent'), -6) : this.renderBalance('transparent') } { this.props.ActiveCoin.coin }
{ Config.roundValues ? formatValue('round', this.renderBalance('transparent'), -6) : this.renderBalance('transparent') }
</span>
</div>
</div>

36
react/src/components/dashboard/walletsNav/walletsNav.js

@ -23,6 +23,7 @@ class WalletsNav extends React.Component {
this.toggleSendReceiveCoinForms = this.toggleSendReceiveCoinForms.bind(this);
this.toggleNativeWalletInfo = this.toggleNativeWalletInfo.bind(this);
this.toggleNativeWalletTransactions = this.toggleNativeWalletTransactions.bind(this);
this.checkTotalBalance = this.checkTotalBalance.bind(this);
}
componentWillMount() {
@ -33,6 +34,41 @@ class WalletsNav extends React.Component {
Store.dispatch(copyCoinAddress(address));
}
checkTotalBalance() {
let _balance = '0';
const _mode = this.props.ActiveCoin.mode;
if (_mode === 'full') {
_balance = this.props.ActiveCoin.balance || 0;
} else if (_mode === 'basilisk') {
if (this.props.ActiveCoin.cache) {
const _cache = this.props.ActiveCoin.cache;
const _coin = this.props.ActiveCoin.coin;
const _address = this.props.ActiveCoin.activeAddress;
if (_address &&
_cache[_coin] &&
_cache[_coin][_address] &&
_cache[_coin][_address].getbalance &&
_cache[_coin][_address].getbalance.data &&
(_cache[_coin][_address].getbalance.data.balance ||
_cache[_coin][_address].getbalance.data.interest)) {
const _regBalance = _cache[_coin][_address].getbalance.data.balance ? _cache[_coin][_address].getbalance.data.balance : 0;
const _regInterest = _cache[_coin][_address].getbalance.data.interest ? _cache[_coin][_address].getbalance.data.interest : 0;
_balance = _regBalance + _regInterest;
}
}
} else if (_mode === 'native') {
if (this.props.ActiveCoin.balance &&
this.props.ActiveCoin.balance.total) {
_balance = this.props.ActiveCoin.balance.total;
}
}
return _balance;
}
toggleSendReceiveCoinForms() {
if (this.props.ActiveCoin.mode === 'native') {
Store.dispatch(

14
react/src/components/dashboard/walletsNav/walletsNav.render.js

@ -52,12 +52,14 @@ export const WalletsNavWithWalletRender = function() {
onClick={ this.props.ActiveCoin.mode !== 'native' ? this.toggleSendReceiveCoinForms : this.toggleNativeWalletTransactions }>
<i className="icon md-view-dashboard"></i> { translate('INDEX.TRANSACTIONS') }
</button>
<button
type="button"
className="btn btn-primary waves-effect waves-light"
onClick={ () => this.toggleSendCoinForm(!this.props.ActiveCoin.send) }>
<i className="icon fa-send"></i> { translate('INDEX.SEND') }
</button>
{ this.checkTotalBalance() > 0 &&
<button
type="button"
className="btn btn-primary waves-effect waves-light"
onClick={ () => this.toggleSendCoinForm(!this.props.ActiveCoin.send) }>
<i className="icon fa-send"></i> { translate('INDEX.SEND') }
</button>
}
<button
type="button"
className="btn btn-success waves-effect waves-light"

Loading…
Cancel
Save