Skip to content

Commit

Permalink
feat(sb): kyc step handling and address normlztion
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip London committed Jun 14, 2020
1 parent 2e8b17c commit abf0da8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Expand Up @@ -18,6 +18,8 @@ import {
import { call, delay, put, select, take } from 'redux-saga/effects'
import { computeSteps } from './services'
import { isEmpty, prop, toUpper } from 'ramda'
import { KycStateType } from 'data/modules/types'
import { RemoteDataType } from 'core/types'
import { StateType, StepsType } from './types'
import { Types } from 'blockchain-wallet-v4/src'
import profileSagas from '../../modules/profile/sagas'
Expand Down Expand Up @@ -158,8 +160,12 @@ export default ({ api, coreSagas, networks }) => {
selectors.core.settings.getSmsVerified
)).getOrElse(0)
const currentStep = yield select(S.getVerificationStep)
const kycState = (selectors.modules.profile.getUserKYCState(
yield select()
) as RemoteDataType<string, KycStateType>).getOrElse('NONE')
const steps = computeSteps({
currentStep,
kycState,
mobileVerified,
needMoreInfo,
smsVerified,
Expand Down
@@ -1,14 +1,23 @@
import { both, compose, filter, flip, gte, lte, prop, values } from 'ramda'

import { KycStateType } from 'data/modules/types'
import { model } from 'data'
import { STEP_TIERS, STEPS } from './model'

export const computeSteps = ({
currentStep,
kycState,
mobileVerified,
needMoreInfo,
smsVerified,
tiers
}: {
currentStep: any
kycState: KycStateType
mobileVerified: boolean
needMoreInfo: boolean
smsVerified: boolean
tiers: any
}) => {
const { TIERS } = model.profile
const { next, selected } = tiers
Expand All @@ -19,6 +28,11 @@ export const computeSteps = ({
const isStepRequired = step => {
if ((!needMoreInfo || next < TIERS[2]) && step === STEPS.moreInfo)
return false
if (
(kycState === 'PENDING' || kycState === 'VERIFIED') &&
step === STEPS.verify
)
return false
if (skipMobile && step === STEPS.mobile) return false

return compose(both(lte(next), gte(selected)), getStepTier)(step)
Expand Down
Expand Up @@ -127,6 +127,7 @@ const Success: React.FC<InjectedFormProps<{}, Props> & Props> = props => {
name='state'
component={SelectBoxUSState}
validate={[required]}
normalize={val => val.name}
/>
) : (
<Field name='state' component={TextBox} />
Expand Down

0 comments on commit abf0da8

Please sign in to comment.