Skip to content

Commit

Permalink
feat(Jumio): address some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed Jul 22, 2018
1 parent 32fc7b8 commit e4eec0f
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ export const SFOX_SELL_BTC_PAYMENT_UPDATED_FAILURE =
'@COMPONENT.SFOX_SELL_BTC_PAYMENT_UPDATED_FAILURE'

export const INITIALIZE_JUMIO = '@COMPONENT.INITIALIZE_JUMIO'
export const GET_JUMIO_STATUS_SUCCESS = '@COMPONENT.GET_JUMIO_STATUS_SUCCESS'
export const GET_JUMIO_STATUS_FAILURE = '@COMPONENT.GET_JUMIO_STATUS_FAILURE'
export const GET_JUMIO_STATUS_LOADING = '@COMPONENT.GET_JUMIO_STATUS_LOADING'

export const GET_JUMIO_TOKEN = '@COMPONENT.GET_JUMIO_TOKEN'
export const GET_JUMIO_TOKEN_SUCCESS = '@COMPONENT.GET_JUMIO_TOKEN_SUCCESS'
export const GET_JUMIO_TOKEN_FAILURE = '@COMPONENT.GET_JUMIO_TOKEN_FAILURE'
export const GET_JUMIO_TOKEN_LOADING = '@COMPONENT.GET_JUMIO_TOKEN_LOADING'
export const FETCH_JUMIO_STATUS_SUCCESS =
'@COMPONENT.FETCH_JUMIO_STATUS_SUCCESS'
export const FETCH_JUMIO_STATUS_FAILURE =
'@COMPONENT.FETCH_JUMIO_STATUS_FAILURE'
export const FETCH_JUMIO_STATUS_LOADING =
'@COMPONENT.FETCH_JUMIO_STATUS_LOADING'

export const FETCH_JUMIO_TOKEN = '@COMPONENT.FETCH_JUMIO_TOKEN'
export const FETCH_JUMIO_TOKEN_SUCCESS = '@COMPONENT.FETCH_JUMIO_TOKEN_SUCCESS'
export const FETCH_JUMIO_TOKEN_FAILURE = '@COMPONENT.FETCH_JUMIO_TOKEN_FAILURE'
export const FETCH_JUMIO_TOKEN_LOADING = '@COMPONENT.FETCH_JUMIO_TOKEN_LOADING'
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,27 @@ export const sfoxSellBtcPaymentUpdatedFailure = err => ({
})

export const initializeJumio = () => ({ type: AT.INITIALIZE_JUMIO })
export const getJumioStatusLoading = () => ({
type: AT.GET_JUMIO_STATUS_LOADING
export const fetchJumioStatusLoading = () => ({
type: AT.FETCH_JUMIO_STATUS_LOADING
})
export const getJumioStatusSuccess = payload => ({
type: AT.GET_JUMIO_STATUS_SUCCESS,
export const fetchJumioStatusSuccess = payload => ({
type: AT.FETCH_JUMIO_STATUS_SUCCESS,
payload
})
export const getJumioStatusFailure = error => ({
type: AT.GET_JUMIO_STATUS_FAILURE,
export const fetchJumioStatusFailure = error => ({
type: AT.FETCH_JUMIO_STATUS_FAILURE,
payload: error
})

export const getJumioToken = () => ({ type: AT.GET_JUMIO_TOKEN })
export const getJumioTokenLoading = () => ({ type: AT.GET_JUMIO_TOKEN_LOADING })
export const getJumioTokenSuccess = payload => ({
type: AT.GET_JUMIO_TOKEN_SUCCESS,
export const fetchJumioToken = () => ({ type: AT.FETCH_JUMIO_TOKEN })
export const fetchJumioTokenLoading = () => ({
type: AT.FETCH_JUMIO_TOKEN_LOADING
})
export const fetchJumioTokenSuccess = payload => ({
type: AT.FETCH_JUMIO_TOKEN_SUCCESS,
payload
})
export const getJumioTokenFailure = error => ({
type: AT.GET_JUMIO_TOKEN_FAILURE,
export const fetchJumioTokenFailure = error => ({
type: AT.FETCH_JUMIO_TOKEN_FAILURE,
payload: error
})
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,22 @@ const sfoxSignup = (state = INITIAL_STATE, action) => {
case AT.SFOX_SELL_BTC_PAYMENT_UPDATED_FAILURE: {
return assoc('payment', Remote.Failure(payload), state)
}
case AT.GET_JUMIO_STATUS_SUCCESS: {
case AT.FETCH_JUMIO_STATUS_SUCCESS: {
return assoc('jumioStatus', Remote.Success(payload), state)
}
case AT.GET_JUMIO_STATUS_LOADING: {
case AT.FETCH_JUMIO_STATUS_LOADING: {
return assoc('jumioStatus', Remote.Loading, state)
}
case AT.GET_JUMIO_STATUS_FAILURE: {
case AT.FETCH_JUMIO_STATUS_FAILURE: {
return assoc('jumioStatus', Remote.Failure(payload), state)
}
case AT.GET_JUMIO_TOKEN_SUCCESS: {
case AT.FETCH_JUMIO_TOKEN_SUCCESS: {
return assoc('jumioToken', Remote.Success(payload), state)
}
case AT.GET_JUMIO_TOKEN_LOADING: {
case AT.FETCH_JUMIO_TOKEN_LOADING: {
return assoc('jumioToken', Remote.Loading, state)
}
case AT.GET_JUMIO_TOKEN_FAILURE: {
case AT.FETCH_JUMIO_TOKEN_FAILURE: {
return assoc('jumioToken', Remote.Failure(payload), state)
}
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export default ({ coreSagas }) => {
yield takeLatest(AT.HANDLE_MODAL_CLOSE, sfoxSagas.checkProfileStatus)
yield takeLatest(AT.SFOX_INITIALIZE_PAYMENT, sfoxSagas.initializePayment)
yield takeLatest(AT.INITIALIZE_JUMIO, sfoxSagas.initializeJumio)
yield takeLatest(AT.GET_JUMIO_TOKEN, sfoxSagas.getJumioToken)
yield takeLatest(AT.FETCH_JUMIO_TOKEN, sfoxSagas.fetchJumioToken)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export default ({ coreSagas }) => {
) {
yield call(coreSagas.data.sfox.refetchProfile)
} else {
yield call(getJumioStatus)
yield call(fetchJumioStatus)
}
}

Expand Down Expand Up @@ -262,7 +262,7 @@ export default ({ coreSagas }) => {

const initializeJumio = function*() {
try {
const status = yield call(getJumioStatus)
const status = yield call(fetchJumioStatus)
const accountsR = yield select(selectors.core.data.sfox.getAccounts)
const accounts = accountsR.getOrElse([])
// If user has not set up jumio and they have bank accounts
Expand All @@ -281,33 +281,33 @@ export default ({ coreSagas }) => {
}
}

const getJumioStatus = function*() {
const fetchJumioStatus = function*() {
try {
yield put(A.getJumioStatusLoading())
yield put(A.fetchJumioStatusLoading())
const profileR = yield select(selectors.core.data.sfox.getProfile)
const tokenR = yield select(selectors.core.kvStore.buySell.getSfoxJumio)
const token = tokenR.getOrFail()
const profile = profileR.getOrElse({})
if (!token) return 'missing_token'
const status = yield apply(profile, profile.getJumioStatus, [token.id])
yield put(A.getJumioStatusSuccess(status))
const status = yield apply(profile, profile.fetchJumioStatus, [token.id])
yield put(A.fetchJumioStatusSuccess(status))
} catch (e) {
yield put(A.getJumioStatusFailure(e))
yield put(A.fetchJumioStatusFailure(e))
}
}

const getJumioToken = function*() {
const fetchJumioToken = function*() {
try {
yield put(A.getJumioTokenLoading())
yield put(A.fetchJumioTokenLoading())
const profileR = yield select(selectors.core.data.sfox.getProfile)
const profile = profileR.getOrElse({})
const token = yield apply(profile, profile.getJumioToken)
const token = yield apply(profile, profile.fetchJumioToken)
yield put(actions.core.kvStore.buySell.sfoxSetJumioToken(token))
yield call(getJumioStatus)
yield put(A.getJumioTokenSuccess(token))
yield call(fetchJumioStatus)
yield put(A.fetchJumioTokenSuccess(token))
} catch (e) {
yield put(A.getJumioTokenFailure(e))
yield put(actions.logs.logErrorMessage(logLocation, 'getJumioToken', e))
yield put(A.fetchJumioTokenFailure(e))
yield put(actions.logs.logErrorMessage(logLocation, 'fetchJumioToken', e))
}
}

Expand All @@ -323,7 +323,7 @@ export default ({ coreSagas }) => {
submitQuote,
submitSellQuote,
initializeJumio,
getJumioToken,
fetchJumioToken,
upload
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class JumioContainer extends React.PureComponent {
}

componentDidMount () {
this.props.sfoxActions.getJumioToken()
this.props.sfoxActions.fetchJumioToken()

let receiveMessage = e => {
const jumioWhitelist = ['done']
Expand All @@ -31,7 +31,7 @@ class JumioContainer extends React.PureComponent {

onFinish () {
const { data } = this.props
const { accounts } = data.getOrElse({})
const { accounts } = data.getOrElse({ accounts: [] })
accounts.length
? this.props.sfoxActions.handleModalClose()
: this.props.sfoxActions.nextStep('funding')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'

import { actions, selectors } from 'data'
import { actions } from 'data'
import { getData } from './selectors'
import { Success } from './template.success'

Expand Down Expand Up @@ -32,8 +32,7 @@ class JumioStatusContainer extends React.PureComponent {
}

const mapStateToProps = state => ({
data: getData(state),
profile: selectors.core.data.sfox.getProfile(state)
data: getData(state)
})

const mapDispatchToProps = dispatch => ({
Expand Down

0 comments on commit e4eec0f

Please sign in to comment.