Skip to content

Commit

Permalink
Merge pull request #5641 from blockchain/fix/active-rewards-learn
Browse files Browse the repository at this point in the history
fix(active-rewards-learn-eligible): fix eligible check
  • Loading branch information
jjBlockchain committed Dec 22, 2022
2 parents 087ec21 + 3d82ad5 commit 30d7a9e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Expand Up @@ -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'
Expand All @@ -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())
Expand Down
15 changes: 10 additions & 5 deletions packages/blockchain-wallet-v4/src/network/api/earn/types.ts
Expand Up @@ -44,12 +44,17 @@ export type EarnBondingDepositsResponseType = {
bondingDeposits: Array<EarnBondingDepositsType>
unbondingWithdrawals: Array<null>
} | 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
Expand Down

0 comments on commit 30d7a9e

Please sign in to comment.