From cc6629ad2772421a7e1a4af51baed0cbb4c22384 Mon Sep 17 00:00:00 2001 From: Art Date: Fri, 27 Oct 2023 13:48:43 +0200 Subject: [PATCH] fix(trading): referrals next tier tiles (#5139) --- .../referrals/referral-statistics.tsx | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/apps/trading/client-pages/referrals/referral-statistics.tsx b/apps/trading/client-pages/referrals/referral-statistics.tsx index 6112b60a0..45d19ffdb 100644 --- a/apps/trading/client-pages/referrals/referral-statistics.tsx +++ b/apps/trading/client-pages/referrals/referral-statistics.tsx @@ -27,6 +27,7 @@ import { useLayoutEffect, useRef, useState } from 'react'; import { useCurrentEpochInfoQuery } from './hooks/__generated__/Epoch'; import BigNumber from 'bignumber.js'; import { t } from '@vegaprotocol/i18n'; +import maxBy from 'lodash/maxBy'; export const ReferralStatistics = () => { const { pubKey } = useVegaWallet(); @@ -102,9 +103,9 @@ export const Statistics = ({ !isNaN(t.discountFactor) && t.discountFactor === discountFactorValue ); - const nextBenefitTierValue = - currentBenefitTierValue && - benefitTiers.find((t) => t.tier === currentBenefitTierValue.tier - 1); + const nextBenefitTierValue = currentBenefitTierValue + ? benefitTiers.find((t) => t.tier === currentBenefitTierValue.tier - 1) + : maxBy(benefitTiers, (bt) => bt.tier); // max tier number is lowest tier const epochsValue = !isNaN(currentEpoch) && refereeInfo?.atEpoch ? currentEpoch - refereeInfo?.atEpoch @@ -189,7 +190,7 @@ export const Statistics = ({ const currentBenefitTierTile = ( - {currentBenefitTierValue?.tier || '-'} + {currentBenefitTierValue?.tier || 'None'} ); const discountFactorTile = ( @@ -204,14 +205,24 @@ export const Statistics = ({ {epochsValue} ); const nextTierVolumeTile = ( - + {nextBenefitTierVolumeValue <= 0 ? '0' : compactNumFormat.format(nextBenefitTierVolumeValue)} ); const nextTierEpochsTile = ( - + {nextBenefitTierEpochsValue <= 0 ? '0' : nextBenefitTierEpochsValue} );