Skip to content

Commit

Permalink
fix(order): fixing order of steps for flexible pricing model
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroapfilho committed Jul 26, 2022
1 parent faf2068 commit 274d30c
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,6 @@ export default ({ api, coreSagas, networks }: { api: APIType; coreSagas: any; ne
delete output.amount
}

let buyOrder: BSOrderType
let oldBuyOrder: BSOrderType | undefined

if (mobilePaymentMethod === MobilePaymentType.APPLE_PAY) {
const applePayInfo: ApplePayInfoType = yield call(api.getApplePayInfo, fiat)

Expand All @@ -402,13 +399,26 @@ export default ({ api, coreSagas, networks }: { api: APIType; coreSagas: any; ne

yield put(A.createOrderLoading())

let buyOrder: BSOrderType

let oldBuyOrder: BSOrderType | undefined

// This code is handles refreshing the buy order when the user sits on
// the order confirmation screen.
while (true) {
// need to get current step and break if not checkout confirm
// usually happens when the user goes back to the enter amount form
const currentStep = S.getStep(yield select())

if (currentStep !== 'CHECKOUT_CONFIRM') {
break
}

// non gold users can only make one order at a time so we need to cancel the old one
if (oldBuyOrder) {
yield call(api.cancelBSOrder, oldBuyOrder)
}

// get the current order, if any
const currentBuyQuote = S.getBuyQuote(yield select()).getOrFail(BS_ERROR.NO_QUOTE)

Expand Down Expand Up @@ -439,12 +449,6 @@ export default ({ api, coreSagas, networks }: { api: APIType; coreSagas: any; ne

// pause the while loop here until if/when the quote expires again, then refresh the order
yield take(A.fetchBuyQuoteSuccess)
// need to get current step and break if not checkout confirm
// usually happens when the user goes back to the enter amount form
const currentStep = S.getStep(yield select())
if (currentStep !== 'CHECKOUT_CONFIRM') {
break
}
}
} catch (e) {
if (isNabuError(e)) {
Expand Down

0 comments on commit 274d30c

Please sign in to comment.