Skip to content

Commit

Permalink
feat(simple buy): use eligible check
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip London committed Mar 28, 2020
1 parent 2d2ba43 commit d39800d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,18 @@ export default ({
currency
}: ReturnType<typeof A.fetchSBFiatEligible>) {
try {
let fiatEligible: FiatEligibleType
yield put(A.fetchSBFiatEligibleLoading())
const fiatEligible: FiatEligibleType = yield call(
api.getSBFiatEligible,
currency
)
// If user is not tier 2 fake eligible check to allow KYC
if (!(yield call(isTier2))) {
fiatEligible = {
eligible: true,
paymentAccountEligible: true,
simpleBuyTradingEligible: true
}
} else {
fiatEligible = yield call(api.getSBFiatEligible, currency)
}
yield put(A.fetchSBFiatEligibleSuccess(fiatEligible))
} catch (e) {
const error = errorHandler(e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { actions, selectors } from 'data'
import { bindActionCreators, Dispatch } from 'redux'
import { connect } from 'react-redux'
import {
FiatEligibleType,
FiatType,
NabuApiErrorType,
RemoteDataType,
Expand All @@ -18,6 +19,7 @@ export type OwnProps = {
handleClose: () => void
}
export type SuccessStateType = {
eligibility: FiatEligibleType
pairs: Array<SBPairType>
}
export type LinkDispatchPropsType = {
Expand All @@ -37,6 +39,7 @@ class EnterAmount extends PureComponent<Props, State> {
componentDidMount () {
if (this.props.fiatCurrency) {
this.props.simpleBuyActions.fetchSBPairs(this.props.fiatCurrency)
this.props.simpleBuyActions.fetchSBFiatEligible(this.props.fiatCurrency)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { selectors } from 'data'

export const getData = state => {
const pairsR = selectors.components.simpleBuy.getSBPairs(state)
const eligibilityR = selectors.components.simpleBuy.getSBFiatEligible(state)

return lift(pairs => ({ pairs }))(pairsR)
return lift((pairs, eligibility) => ({ pairs, eligibility }))(
pairsR,
eligibilityR
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type Props = OwnProps &
LinkStatePropsType

const Success: React.FC<Props> = props => {
return props.pairs.length ? (
return props.pairs.length && props.eligibility.eligible ? (
<Checkout {...props} />
) : (
<Unsupported {...props} />
Expand Down

This file was deleted.

0 comments on commit d39800d

Please sign in to comment.