Skip to content

Commit

Permalink
fix(sell p2): remove suggested amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip London committed Aug 7, 2020
1 parent 3bfecdd commit fb3c985
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 239 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,6 @@ export const FETCH_SB_QUOTE_FAILURE = '@EVENT.FETCH_SB_QUOTE_FAILURE'
export const FETCH_SB_QUOTE_LOADING = '@EVENT.FETCH_SB_QUOTE_LOADING'
export const FETCH_SB_QUOTE_SUCCESS = '@EVENT.FETCH_SB_QUOTE_SUCCESS'

export const FETCH_SB_SUGGESTED_AMOUNTS = '@EVENT.FETCH_SB_SUGGESTED_AMOUNTS'
export const FETCH_SB_SUGGESTED_AMOUNTS_FAILURE =
'@EVENT.FETCH_SB_SUGGESTED_AMOUNTS_FAILURE'
export const FETCH_SB_SUGGESTED_AMOUNTS_LOADING =
'@EVENT.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'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as AT from './actionTypes'
import {
CoinType,
CurrenciesType,
Everypay3DSResponseType,
FiatEligibleType,
FiatType,
Expand All @@ -15,7 +14,6 @@ import {
SBPaymentMethodType,
SBProviderDetailsType,
SBQuoteType,
SBSuggestedAmountType,
WalletFiatType
} from 'core/types'
import { ModalOriginType } from 'data/modals/types'
Expand Down Expand Up @@ -344,33 +342,6 @@ export const fetchSBQuoteSuccess = (
}
})

export const fetchSBSuggestedAmounts = (currency: keyof CurrenciesType) => ({
type: AT.FETCH_SB_SUGGESTED_AMOUNTS,
currency
})

export const fetchSBSuggestedAmountsFailure = (
error: Error | string
): SimpleBuyActionTypes => ({
type: AT.FETCH_SB_SUGGESTED_AMOUNTS_FAILURE,
payload: {
error
}
})

export const fetchSBSuggestedAmountsLoading = (): SimpleBuyActionTypes => ({
type: AT.FETCH_SB_SUGGESTED_AMOUNTS_LOADING
})

export const fetchSBSuggestedAmountsSuccess = (
amounts: SBSuggestedAmountType
): SimpleBuyActionTypes => ({
type: AT.FETCH_SB_SUGGESTED_AMOUNTS_SUCCESS,
payload: {
amounts
}
})

export const handleSBDepositFiatClick = (
coin: WalletFiatType,
origin: ModalOriginType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,26 @@ import { SimpleBuyActionTypes, SimpleBuyState } from './types'
import Remote from 'blockchain-wallet-v4/src/remote/remote'

const INITIAL_STATE: SimpleBuyState = {
orderType: undefined,
account: Remote.NotAsked,
balances: Remote.NotAsked,
card: Remote.NotAsked,
cardId: undefined,
cards: Remote.NotAsked,
displayBack: false,
cryptoCurrency: undefined,
displayBack: false,
everypay3DS: Remote.NotAsked,
fiatCurrency: undefined,
fiatEligible: Remote.NotAsked,
method: undefined,
methods: Remote.NotAsked,
order: undefined,
orders: Remote.NotAsked,
pairs: Remote.NotAsked,
orderType: undefined,
pair: undefined,
pairs: Remote.NotAsked,
providerDetails: Remote.NotAsked,
quote: Remote.NotAsked,
step: 'CURRENCY_SELECTION',
suggestedAmounts: Remote.NotAsked
step: 'CURRENCY_SELECTION'
}

export function simpleBuyReducer (
Expand Down Expand Up @@ -73,8 +72,7 @@ export function simpleBuyReducer (
order: undefined,
pairs: Remote.NotAsked,
quote: Remote.NotAsked,
step: 'CURRENCY_SELECTION',
suggestedAmounts: Remote.NotAsked
step: 'CURRENCY_SELECTION'
}
case AT.FETCH_SB_BALANCES_FAILURE: {
return {
Expand Down Expand Up @@ -221,22 +219,6 @@ export function simpleBuyReducer (
...state,
quote: Remote.Success(action.payload.quote)
}
case AT.FETCH_SB_SUGGESTED_AMOUNTS_FAILURE: {
return {
...state,
suggestedAmounts: Remote.Failure(action.payload.error)
}
}
case AT.FETCH_SB_SUGGESTED_AMOUNTS_LOADING:
return {
...state,
suggestedAmounts: Remote.Loading
}
case AT.FETCH_SB_SUGGESTED_AMOUNTS_SUCCESS:
return {
...state,
suggestedAmounts: Remote.Success(action.payload.amounts)
}
case AT.INITIALIZE_CHECKOUT:
return {
...state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ export default ({ api, coreSagas, networks }) => {
simpleBuySagas.fetchSBPaymentMethods
)
yield takeLatest(AT.FETCH_SB_QUOTE, simpleBuySagas.fetchSBQuote)
yield takeLatest(
AT.FETCH_SB_SUGGESTED_AMOUNTS,
simpleBuySagas.fetchSBSuggestedAmounts
)
yield takeLatest(
AT.HANDLE_SB_DEPOSIT_FIAT_CLICK,
simpleBuySagas.handleSBDepositFiatClick
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,19 +527,6 @@ export default ({
}
}

const fetchSBSuggestedAmounts = function * ({
currency
}: ReturnType<typeof A.fetchSBSuggestedAmounts>) {
try {
yield put(A.fetchSBSuggestedAmountsLoading())
const amounts = yield call(api.getSBSuggestedAmounts, currency)
yield put(A.fetchSBSuggestedAmountsSuccess(amounts))
} catch (e) {
const error = errorHandler(e)
yield put(A.fetchSBSuggestedAmountsFailure(error))
}
}

const handleSBDepositFiatClick = function * ({
payload
}: ReturnType<typeof A.handleSBDepositFiatClick>) {
Expand Down Expand Up @@ -682,8 +669,6 @@ export default ({
const fiatCurrency = S.getFiatCurrency(yield select())
if (!fiatCurrency) throw new Error(NO_FIAT_CURRENCY)

yield put(A.fetchSBSuggestedAmounts(fiatCurrency))

yield put(
actions.form.initialize('simpleBuyCheckout', {
orderType,
Expand Down Expand Up @@ -850,7 +835,6 @@ export default ({
fetchSBPaymentAccount,
fetchSBPaymentMethods,
fetchSBQuote,
fetchSBSuggestedAmounts,
handleSBDepositFiatClick,
handleSBSuggestedAmountClick,
handleSBMethodChange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,4 @@ export const getSBLatestPendingOrder = (state: RootState) =>
)
})

export const getSBSuggestedAmounts = (state: RootState) =>
state.components.simpleBuy.suggestedAmounts

export const getStep = (state: RootState) => state.components.simpleBuy.step
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import {
SBPaymentMethodsType,
SBPaymentMethodType,
SBProviderDetailsType,
SBQuoteType,
SBSuggestedAmountType
SBQuoteType
} from 'core/types'

// Types
Expand Down Expand Up @@ -89,7 +88,6 @@ export type SimpleBuyState = {
providerDetails: RemoteDataType<string, SBProviderDetailsType>
quote: RemoteDataType<string, SBQuoteType>
step: keyof typeof SimpleBuyStepType
suggestedAmounts: RemoteDataType<Error | string, SBSuggestedAmountType>
}

// Actions
Expand Down Expand Up @@ -273,21 +271,6 @@ interface FetchSBQuoteSuccess {
}
type: typeof AT.FETCH_SB_QUOTE_SUCCESS
}
interface FetchSBSuggestedAmountsFailure {
payload: {
error: Error | string
}
type: typeof AT.FETCH_SB_SUGGESTED_AMOUNTS_FAILURE
}
interface FetchSBSuggestedAmountsLoading {
type: typeof AT.FETCH_SB_SUGGESTED_AMOUNTS_LOADING
}
interface FetchSBSuggestedAmountsSuccess {
payload: {
amounts: SBSuggestedAmountType
}
type: typeof AT.FETCH_SB_SUGGESTED_AMOUNTS_SUCCESS
}

interface InitializeCheckout {
amount: string
Expand Down Expand Up @@ -385,9 +368,6 @@ export type SimpleBuyActionTypes =
| FetchSBQuoteFailure
| FetchSBQuoteLoading
| FetchSBQuoteSuccess
| FetchSBSuggestedAmountsFailure
| FetchSBSuggestedAmountsLoading
| FetchSBSuggestedAmountsSuccess
| InitializeCheckout
| SetStepAction
| ShowModalAction
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ export const getData = (state: RootState) => {
)
const invitationsR = selectors.core.settings.getInvitations(state)
const ratesR = selectors.core.data.misc.getRatesSelector(coin, state)
const suggestedAmountsR = selectors.components.simpleBuy.getSBSuggestedAmounts(
state
)
const sbBalancesR = selectors.components.simpleBuy.getSBBalances(state)
const userDataR = selectors.modules.profile.getUserData(state)

Expand All @@ -21,15 +18,13 @@ export const getData = (state: RootState) => {
invitations: ExtractSuccess<typeof invitationsR>,
rates: ExtractSuccess<typeof ratesR>,
sbBalances: ExtractSuccess<typeof sbBalancesR>,
suggestedAmounts: ExtractSuccess<typeof suggestedAmountsR>,
userData: ExtractSuccess<typeof userDataR>
) => ({
formErrors,
invitations,
rates,
sbBalances,
suggestedAmounts,
userData
})
)(invitationsR, ratesR, sbBalancesR, suggestedAmountsR, userDataR)
)(invitationsR, ratesR, sbBalancesR, userDataR)
}

0 comments on commit fb3c985

Please sign in to comment.