Skip to content

Commit

Permalink
feat(sb): launch kyc verification from deposit click
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip London committed Jul 25, 2020
1 parent 83f369f commit aa832b3
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 16 deletions.
Expand Up @@ -80,6 +80,9 @@ export const FETCH_SB_SUGGESTED_AMOUNTS_LOADING =
export const FETCH_SB_SUGGESTED_AMOUNTS_SUCCESS =
'@EVENT.FETCH_SB_SUGGESTED_AMOUNTS_SUCCESS'

export const HANDLE_SB_DEPOSIT_FIAT_CLICK =
'@EVENT.HANDLE_SB_DEPOSIT_FIAT_CLICK'

export const HANDLE_SB_METHOD_CHANGE = '@EVENT.HANDLE_SB_METHOD_CHANGE'

export const HANDLE_SB_SUGGESTED_AMOUNT_CLICK =
Expand Down
Expand Up @@ -15,8 +15,10 @@ import {
SBPaymentMethodType,
SBProviderDetailsType,
SBQuoteType,
SBSuggestedAmountType
SBSuggestedAmountType,
WalletFiatType
} from 'core/types'
import { ModalOriginType } from 'data/modals/types'
import {
SBShowModalOriginType,
SimpleBuyActionTypes,
Expand Down Expand Up @@ -368,6 +370,17 @@ export const fetchSBSuggestedAmountsSuccess = (
}
})

export const handleSBDepositFiatClick = (
coin: WalletFiatType,
origin: ModalOriginType
) => ({
type: AT.HANDLE_SB_DEPOSIT_FIAT_CLICK,
payload: {
coin,
origin
}
})

export const handleSBSuggestedAmountClick = (amount: string) => ({
type: AT.HANDLE_SB_SUGGESTED_AMOUNT_CLICK,
payload: {
Expand Down
Expand Up @@ -42,6 +42,10 @@ export default ({ api, coreSagas, networks }) => {
AT.FETCH_SB_SUGGESTED_AMOUNTS,
simpleBuySagas.fetchSBSuggestedAmounts
)
yield takeLatest(
AT.HANDLE_SB_DEPOSIT_FIAT_CLICK,
simpleBuySagas.handleSBDepositFiatClick
)
yield takeLatest(
AT.HANDLE_SB_METHOD_CHANGE,
simpleBuySagas.handleSBMethodChange
Expand Down
Expand Up @@ -515,6 +515,31 @@ export default ({
}
}

const handleSBDepositFiatClick = function * ({
payload
}: ReturnType<typeof A.handleSBDepositFiatClick>) {
const { coin, origin } = payload

yield call(waitForUserData)
const isUserTier2 = yield call(isTier2)

if (!isUserTier2) {
yield put(
actions.components.identityVerification.verifyIdentity(2, false, origin)
)
} else {
yield put(A.showModal('EmptyFeed'))

yield put(
A.setStep({
step: 'TRANSFER_DETAILS',
displayBack: false,
fiatCurrency: coin
})
)
}
}

const handleSBSuggestedAmountClick = function * ({
payload
}: ReturnType<typeof A.handleSBSuggestedAmountClick>) {
Expand Down Expand Up @@ -759,6 +784,7 @@ export default ({
fetchSBPaymentMethods,
fetchSBQuote,
fetchSBSuggestedAmounts,
handleSBDepositFiatClick,
handleSBSuggestedAmountClick,
handleSBMethodChange,
initializeBillingAddress,
Expand Down
Expand Up @@ -80,12 +80,10 @@ const Welcome = (props: OwnProps & { handleRequest: () => void }) => {
nature='empty-blue'
onClick={() => {
if (props.coin in WalletFiatEnum) {
props.simpleBuyActions.showModal('EmptyFeed')
props.simpleBuyActions.setStep({
step: 'TRANSFER_DETAILS',
displayBack: false,
fiatCurrency: props.coin as WalletFiatType
})
props.simpleBuyActions.handleSBDepositFiatClick(
props.coin as WalletFiatType,
'TransactionList'
)
} else {
props.simpleBuyActions.showModal('EmptyFeed', props.coin)
}
Expand Down
Expand Up @@ -5,8 +5,8 @@ import {
CoinType,
CoinTypeEnum,
FiatType,
FiatTypeEnum,
SupportedCoinType,
WalletFiatEnum,
WalletFiatType
} from 'core/types'
import { connect, ConnectedProps } from 'react-redux'
Expand Down Expand Up @@ -133,19 +133,17 @@ class TransactionsContainer extends React.PureComponent<Props> {
</Text>
</CoinTitle>
<TitleActionContainer>
{coin in FiatTypeEnum && (
{coin in WalletFiatEnum && (
<Button
nature='primary'
data-e2e='depositFiat'
style={{ minWidth: 'auto' }}
onClick={() => {
if (!this.props.simpleBuyActions) return
this.props.simpleBuyActions.showModal('EmptyFeed')
this.props.simpleBuyActions.setStep({
step: 'TRANSFER_DETAILS',
displayBack: false,
fiatCurrency: coin as WalletFiatType
})
this.props.simpleBuyActions.handleSBDepositFiatClick(
coin as WalletFiatType,
'TransactionList'
)
}}
>
Deposit
Expand Down Expand Up @@ -216,7 +214,7 @@ const mapDispatchToProps = (dispatch: Dispatch, ownProps) => {
miscActions: bindActionCreators(actions.core.data.misc, dispatch)
}
}
if (coin in FiatTypeEnum) {
if (coin in WalletFiatEnum) {
return {
fetchData: () => {},
loadMoreTxs: () =>
Expand Down

0 comments on commit aa832b3

Please sign in to comment.