From feb5f5a01a35dbeb62e1fa25021868961842f01e Mon Sep 17 00:00:00 2001 From: pbca26 Date: Wed, 2 Aug 2017 16:40:00 +0300 Subject: [PATCH] hide send btn if zero balance --- .../walletsBalance/walletsBalance.render.js | 2 +- .../dashboard/walletsNav/walletsNav.js | 36 +++++++++++++++++++ .../dashboard/walletsNav/walletsNav.render.js | 14 ++++---- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/react/src/components/dashboard/walletsBalance/walletsBalance.render.js b/react/src/components/dashboard/walletsBalance/walletsBalance.render.js index 4d28a63..01a818b 100644 --- a/react/src/components/dashboard/walletsBalance/walletsBalance.render.js +++ b/react/src/components/dashboard/walletsBalance/walletsBalance.render.js @@ -38,7 +38,7 @@ const WalletsBalanceRender = function() { - { 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') } diff --git a/react/src/components/dashboard/walletsNav/walletsNav.js b/react/src/components/dashboard/walletsNav/walletsNav.js index cfe7ddb..4b17767 100644 --- a/react/src/components/dashboard/walletsNav/walletsNav.js +++ b/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( diff --git a/react/src/components/dashboard/walletsNav/walletsNav.render.js b/react/src/components/dashboard/walletsNav/walletsNav.render.js index e16a91e..67d43a7 100644 --- a/react/src/components/dashboard/walletsNav/walletsNav.render.js +++ b/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 }> { translate('INDEX.TRANSACTIONS') } - + { this.checkTotalBalance() > 0 && + + }