From 831651e7f30416d620e4543cce0eae1da127576d Mon Sep 17 00:00:00 2001 From: Madalina Raicu Date: Wed, 28 Feb 2024 20:15:12 +0000 Subject: [PATCH] fix: staking rewards filter --- .../rewards-container/active-rewards.tsx | 48 ++++++++++--------- apps/trading/lib/hooks/use-rewards.ts | 9 ++-- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/apps/trading/components/rewards-container/active-rewards.tsx b/apps/trading/components/rewards-container/active-rewards.tsx index eefc3e64e..ca468240d 100644 --- a/apps/trading/components/rewards-container/active-rewards.tsx +++ b/apps/trading/components/rewards-container/active-rewards.tsx @@ -27,6 +27,7 @@ import { AccountType, DistributionStrategy, IndividualScope, + type Asset, } from '@vegaprotocol/types'; import { Card } from '../card/card'; import { type ReactNode, useState } from 'react'; @@ -182,6 +183,29 @@ export const ActiveRewardCard = ({ return null; } + if ( + !transferNode.transfer.kind.dispatchStrategy && + transferNode.transfer.toAccountType === + AccountType.ACCOUNT_TYPE_GLOBAL_REWARD + ) { + return ( + + ); + } + let colour = DispatchMetricColourMap[ transferNode.transfer.kind.dispatchStrategy.dispatchMetric @@ -201,28 +225,6 @@ export const ActiveRewardCard = ({ colour = CardColour.GREY; } - if ( - transferNode.transfer.toAccountType === - AccountType.ACCOUNT_TYPE_GLOBAL_REWARD - ) { - return ( - - ); - } - return ( { if ( - node.transfer.kind.__typename === 'RecurringTransfer' && - node.transfer.kind.dispatchStrategy != null + (node.transfer.kind.__typename === 'RecurringTransfer' && + node.transfer.kind.dispatchStrategy != null) || + node.transfer.toAccountType === AccountType.ACCOUNT_TYPE_GLOBAL_REWARD ) { return true; } @@ -142,6 +144,7 @@ export const useRewards = ({ .filter((node) => (scopeToTeams ? isScopedToTeams(node) : true)) // enrich with dispatch asset and markets in scope details .map((node) => { + if (!node.transfer.kind.dispatchStrategy) return node; const asset = assets && assets[node.transfer.kind.dispatchStrategy.dispatchMetricAssetId]; @@ -169,7 +172,7 @@ export const useRewards = ({ ...node, asset: asset ? asset : undefined, isAssetTraded: isAssetTraded != null ? isAssetTraded : undefined, - markets: marketsInScope.length > 0 ? marketsInScope : undefined, + markets: marketsInScope?.length > 0 ? marketsInScope : undefined, }; });