From f3afb6f94dfda92c90a53a251a33c4b7f589357f Mon Sep 17 00:00:00 2001 From: Dmitriy Korniychuk Date: Mon, 17 Jun 2019 16:06:38 +0300 Subject: [PATCH] market fee sharing feature bug #2770 --- app/components/Account/AccountVesting.jsx | 146 ++++++++++++---------- 1 file changed, 83 insertions(+), 63 deletions(-) diff --git a/app/components/Account/AccountVesting.jsx b/app/components/Account/AccountVesting.jsx index 46dc073acb..314cb6c728 100644 --- a/app/components/Account/AccountVesting.jsx +++ b/app/components/Account/AccountVesting.jsx @@ -27,18 +27,23 @@ class VestingBalance extends React.Component { } let cvbAsset, - vestingPeriod, - earned, secondsPerDay = 60 * 60 * 24, - availablePercent, balance; + let vestingPeriod = null; + let earned = null; + let availablePercent = null; if (vb) { balance = vb.balance.amount; cvbAsset = ChainStore.getAsset(vb.balance.asset_id); - earned = vb.policy[1].coin_seconds_earned; - vestingPeriod = vb.policy[1].vesting_seconds; - availablePercent = - vestingPeriod === 0 ? 1 : earned / (vestingPeriod * balance); + + if (vb.policy && vb.policy[0] !== 2) { + earned = vb.policy[1].coin_seconds_earned; + vestingPeriod = vb.policy[1].vesting_seconds; + availablePercent = + vestingPeriod === 0 + ? 1 + : earned / (vestingPeriod * balance); + } } if (!cvbAsset) { @@ -78,66 +83,81 @@ class VestingBalance extends React.Component { /> - - - - - - {utils.format_number( - utils.get_asset_amount( - earned / secondsPerDay, - cvbAsset - ), - 0 - )} -   - - - - - - - - - {utils.format_number( - utils.get_asset_amount( - (vb.balance.amount * vestingPeriod) / - secondsPerDay, - cvbAsset - ), - 0 - )} -   - - - - - - - - - {utils.format_number( - (vestingPeriod * (1 - availablePercent)) / - secondsPerDay || 0, - 2 - )} -  days - - + {earned && ( + + + + + + {utils.format_number( + utils.get_asset_amount( + earned / secondsPerDay, + cvbAsset + ), + 0 + )} +   + + + + )} + {earned && ( + + + + + + {utils.format_number( + utils.get_asset_amount( + (vb.balance.amount * + vestingPeriod) / + secondsPerDay, + cvbAsset + ), + 0 + )} +   + + + + )} + {earned && ( + + + + + + {utils.format_number( + (vestingPeriod * + (1 - availablePercent)) / + secondsPerDay || 0, + 2 + )} +  days + + + )} - - {utils.format_number(availablePercent * 100, 2)} - % /{" "} - - + {earned ? ( + + {utils.format_number( + availablePercent * 100, + 2 + )} + % /{" "} + + + ) : ( + {utils.format_number(100, 2)}% + )}