From abf0da89b4ce3ecaceb2b0307fb2d4232d4f90b2 Mon Sep 17 00:00:00 2001 From: Philip London Date: Sun, 14 Jun 2020 11:37:58 +0200 Subject: [PATCH] feat(sb): kyc step handling and address normlztion --- .../data/components/identityVerification/sagas.ts | 6 ++++++ .../components/identityVerification/services.ts | 14 ++++++++++++++ .../SimpleBuy/BillingAddress/template.success.tsx | 1 + 3 files changed, 21 insertions(+) diff --git a/packages/blockchain-wallet-v4-frontend/src/data/components/identityVerification/sagas.ts b/packages/blockchain-wallet-v4-frontend/src/data/components/identityVerification/sagas.ts index cf0abbad845..b1e37ba5b00 100644 --- a/packages/blockchain-wallet-v4-frontend/src/data/components/identityVerification/sagas.ts +++ b/packages/blockchain-wallet-v4-frontend/src/data/components/identityVerification/sagas.ts @@ -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' @@ -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).getOrElse('NONE') const steps = computeSteps({ currentStep, + kycState, mobileVerified, needMoreInfo, smsVerified, diff --git a/packages/blockchain-wallet-v4-frontend/src/data/components/identityVerification/services.ts b/packages/blockchain-wallet-v4-frontend/src/data/components/identityVerification/services.ts index 16416da5c1b..89809e0724a 100644 --- a/packages/blockchain-wallet-v4-frontend/src/data/components/identityVerification/services.ts +++ b/packages/blockchain-wallet-v4-frontend/src/data/components/identityVerification/services.ts @@ -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 @@ -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) diff --git a/packages/blockchain-wallet-v4-frontend/src/modals/SimpleBuy/BillingAddress/template.success.tsx b/packages/blockchain-wallet-v4-frontend/src/modals/SimpleBuy/BillingAddress/template.success.tsx index 29b40cb6574..ec70851488a 100644 --- a/packages/blockchain-wallet-v4-frontend/src/modals/SimpleBuy/BillingAddress/template.success.tsx +++ b/packages/blockchain-wallet-v4-frontend/src/modals/SimpleBuy/BillingAddress/template.success.tsx @@ -127,6 +127,7 @@ const Success: React.FC & Props> = props => { name='state' component={SelectBoxUSState} validate={[required]} + normalize={val => val.name} /> ) : (