-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: APP-410 save buy flow on last user interaction #2574
base: dev
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for regen-website ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for terrasos ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@erikalogie see testing instructions |
LGTM |
fef3652
to
0b294da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two additional comments:
- We don't save values for the last step to local storage
- When using credit card, if the user leaves the page while being on the last step, when he comes back, we should go back to step 2 (Payment info) because we need the user to re-enter credit card info since this is something we can't save to local storage of course
web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.tsx
Outdated
Show resolved
Hide resolved
web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.tsx
Show resolved
Hide resolved
web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.tsx
Show resolved
Hide resolved
web-marketplace/src/components/molecules/CreditsAmount/CurrencyInput.tsx
Outdated
Show resolved
Hide resolved
web-marketplace/src/components/organisms/PaymentInfoForm/PaymentInfoForm.tsx
Outdated
Show resolved
Hide resolved
@erikalogie can you review the changes mentioned in this comment please #2574 (review) |
LGTM |
LGTM ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name: 'postalCode', | ||
}); | ||
|
||
const { anonymousPurchase, followProject, subscribeNewsletter, agreeErpa } = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be more appropriate to move that getValues()
into the useEffect
that uses them, looks like we don't need them at the component top level
this is also going to cause a bug when we enable anonymousPurchase
checkbox (commented for now) because we use it in the checked
prop and getValues
does not subscribe to input change, which will cause the checkbox to be unresponsive, that's why we use useWatch
instead, which you commented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this would only cause a bug if we wouldn't update the getValues
when we uncomment the anonymousPurchase
field. However, it'd probably be better to use useWatch
for all fields. I've made the update, please review.
I've changed the way we handle @erikalogie @S4mmyb have a look how the currency and credits fields behave now when a user leaves the inputs with a value of zero or empty, let me know if you want to change anything. @blushi although the CI shows some failed tests they weren't related with the code updates and a redeploy seems to have been successful: https://app.netlify.com/sites/regen-website/deploys/6788180794db4932a06dce1f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the way we handle
onBlur
when a user leaves the credits and currency inputs. Now if a user leaves the input with a value of0
or empty''
I'm resetting the credits to1
and then setting the corresponding currency amount.
We should also reset the SELL_ORDERS value in this case. If I set one of the field to 0, then the currency/amount fields do update but not the selected sell orders
Here's how my local storage looks like after that:
and then when I go through the end of the flow, I cannot purchase because I'm getting an "invalid amount" error from our server endpoint /marketplace/v1/stripe/create-payment-intent since quantity is NaN
const stripeAmount = | ||
data?.[CURRENCY_AMOUNT] || | ||
getCurrencyAmount({ | ||
currentCreditsAmount: 1, | ||
card: paymentOption === PAYMENT_OPTIONS.CARD, | ||
orderedSellOrders: cardSellOrders, | ||
creditTypePrecision: creditTypeData?.creditType?.precision, | ||
}).currencyAmount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we put this in a useMemo
too? getCurrencyAmount
is a bit computation heavy
I think this is fine? @S4mmyb wdyt |
Description
https://regennetwork.atlassian.net/browse/APP-410
Now when users interact with the forms the information should be stored in the localstorage automatically even when the next button hasn't been clicked yet, and therefore, on navigating away and back to the same page, users should be in the same step and see the same form data as before navigating away.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
How to test
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...