Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(active-rewards-learn-eligible): fix eligible check #5641

Merged
merged 1 commit into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

packages/blockchain-wallet-v4/src/network/api/earn/types.ts**

Suggested change
ineligibilityReason: 'KYC_TIER' | 'BLOCKED' | 'REGION' | 'UNSUPPORTED_COUNTRY_OR_STATE' | null
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