Skip to content

Commit

Permalink
feat(sb): only show fiat in side naav if user is eligible
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip London committed Jul 16, 2020
1 parent 08f55b4 commit bcaaf4f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 4 deletions.
Expand Up @@ -143,6 +143,7 @@ export default ({ api, coreSagas }) => {
const language = yield select(selectors.preferences.getLanguage)
yield put(actions.modules.settings.updateLanguage(language))
yield put(actions.analytics.initUserSession())
yield put(actions.components.simpleBuy.fetchSBPaymentMethods())
yield fork(checkDataErrors)
yield fork(logoutRoutine, yield call(setLogoutEventListener))
} catch (e) {
Expand Down
Expand Up @@ -451,9 +451,14 @@ export default ({
currency
}: ReturnType<typeof A.fetchSBPaymentMethods>) {
try {
yield call(createUser)
yield call(waitForUserData)
const isUserTier2: boolean = yield call(isTier2)
if (!isUserTier2) {
return yield put(
A.fetchSBPaymentMethodsSuccess({ currency: 'USD', methods: [] })
)
}
yield call(createUser)
yield put(A.fetchSBPaymentMethodsLoading())
const methods = yield call(
api.getSBPaymentMethods,
Expand Down
Expand Up @@ -98,6 +98,7 @@ const Navigation = (props: OwnProps & Props) => {
mapObjIndexed(
(coin: SupportedCoinType, i) =>
coin &&
coin.method &&
coin.invited &&
coin.txListAppRoute && (
<LinkContainer
Expand Down
Expand Up @@ -101,6 +101,7 @@ export type SBPairType = {
}

export type SBPaymentMethodType = {
currency: FiatType
limits: {
max: string
min: string
Expand Down
22 changes: 19 additions & 3 deletions packages/blockchain-wallet-v4/src/redux/walletOptions/selectors.ts
Expand Up @@ -11,7 +11,9 @@ import {
set,
toUpper
} from 'ramda'
import { FiatTypeEnum } from 'blockchain-wallet-v4/src/types'
import { getInvitations } from '../settings/selectors'
import { getSBPaymentMethods } from 'data/components/simpleBuy/selectors'
import { RootState } from 'data/rootReducer'
import { SupportedCoinType } from './types'

Expand All @@ -34,15 +36,29 @@ export const getAdsUrl = state => getWebOptions(state).map(path(['ads', 'url']))

// coins
export const getSupportedCoins = createDeepEqualSelector(
[getInvitations, getWebOptions],
(invitationsR, webOptionsR) => {
[getInvitations, getWebOptions, getSBPaymentMethods],
(invitationsR, webOptionsR, sbPaymentMethods) => {
const addInvited = (obj, coin) => {
// @ts-ignore
const invited = invitationsR.map(propOr(true, coin)).getOrElse(false)
return set(lensProp('invited'), invited, obj)
}
const addMethod = (obj, coin) => {
const methods = sbPaymentMethods.getOrElse({
currency: 'USD',
methods: []
})
const method =
coin in FiatTypeEnum
? methods.methods.find(method => method.currency === coin)
: true
return set(lensProp('method'), method, obj)
}

return webOptionsR.map(prop('coins')).map(mapObjIndexed(addInvited))
return webOptionsR
.map(prop('coins'))
.map(mapObjIndexed(addInvited))
.map(mapObjIndexed(addMethod))
}
)
export const getSyncToExchangeList = state =>
Expand Down
Expand Up @@ -29,6 +29,7 @@ export type SupportedCoinType = {
}
invited?: boolean
learnMoreLink: string
method?: boolean
minConfirmations: number
showNewTagSidenav: boolean
txExplorerBaseUrl: string
Expand All @@ -48,6 +49,7 @@ export type SupportedFiatType = {
}
invited?: boolean
learnMoreLink: ''
method?: boolean
minConfirmations: 0
txExplorerBaseUrl: ''
txListAppRoute: string
Expand Down

0 comments on commit bcaaf4f

Please sign in to comment.