diff --git a/packages/blockchain-wallet-v4-frontend/src/scenes/ActiveRewardsLearn/Header/index.tsx b/packages/blockchain-wallet-v4-frontend/src/scenes/ActiveRewardsLearn/Header/index.tsx index a96ec1abd0f..ccc2a3d3312 100644 --- a/packages/blockchain-wallet-v4-frontend/src/scenes/ActiveRewardsLearn/Header/index.tsx +++ b/packages/blockchain-wallet-v4-frontend/src/scenes/ActiveRewardsLearn/Header/index.tsx @@ -5,7 +5,7 @@ import { LinkContainer } from 'react-router-bootstrap' import { Button, Flex, IconChevronLeft, SemanticColors, Text } from '@blockchain-com/constellation' import styled from 'styled-components' -import { CoinType } from '@core/types' +import { CoinType, EarnEligibleType } from '@core/types' import { Link } from 'blockchain-info-components' import { actions, selectors } from 'data' import { RootState } from 'data/rootReducer' @@ -16,11 +16,12 @@ const CustomLink = styled(Link)` const Header = () => { const dispatch = useDispatch() - const eligible = useSelector((state: RootState) => + const eligible: EarnEligibleType = useSelector((state: RootState) => selectors.components.interest.getActiveRewardsEligible(state).getOrElse({}) ) const eligibleCoins: CoinType[] = Object.keys(eligible) - const isEligible = eligibleCoins.length > 0 + const isEligible = + eligibleCoins.length > 0 && (eligible.eligible || eligible[eligibleCoins[0]].eligible) useEffect(() => { dispatch(actions.components.interest.fetchActiveRewardsEligible()) diff --git a/packages/blockchain-wallet-v4/src/network/api/earn/types.ts b/packages/blockchain-wallet-v4/src/network/api/earn/types.ts index ad2ac23442e..ca32ef5dd33 100644 --- a/packages/blockchain-wallet-v4/src/network/api/earn/types.ts +++ b/packages/blockchain-wallet-v4/src/network/api/earn/types.ts @@ -44,12 +44,17 @@ export type EarnBondingDepositsResponseType = { bondingDeposits: Array unbondingWithdrawals: Array } | null -export type EarnEligibleType = { - [key in CoinType]?: { - eligible: boolean - ineligibilityReason: 'KYC_TIER' | 'BLOCKED' | 'REGION' | 'UNSUPPORTED_COUNTRY_OR_STATE' | null - } + +// If user is eligible it will send {coin: eligibleType} otherwise it will send EligibleType only +type EligibleType = { + eligible: boolean + ineligibilityReason: 'KYC_TIER' | 'BLOCKED' | 'REGION' | 'UNSUPPORTED_COUNTRY_OR_STATE' | null } +export type EarnEligibleType = + | { + [key in CoinType]?: EligibleType + } + | EligibleType export type EarnTransactionParamType = { currency?: CoinType