Skip to content
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

[Hooks integration] Checkout Payment Section + Checkout Confirmation Page #1075

Merged
merged 45 commits into from
Mar 23, 2023

Conversation

kevinxh
Copy link
Collaborator

@kevinxh kevinxh commented Mar 21, 2023

This PR converts the checkout payment section to use commerce-sdk-react hooks. This PR also includes the switch from OCAPI to SCAPI for checkout on retail react app.

Important UX changes

There is a significant change in terms of how payment is handled on SCAPI. Apparently SCAPI no longer accepts customer_payment_instrument_id as an input, which means that shoppers will not be able to apply their saved payments to the basket. The saved payments feature on retail react app becomes meaningless, and we have decided to remove the following UI components:

  • account payments page
  • checkout select saved payment component

Screenshot 2023-03-17 at 11 22 42 AM

Screenshot 2023-03-17 at 11 22 32 AM

Screenshot 2023-03-17 at 11 21 00 AM

Changes:

  • convert checkout confirmation page to use hooks
  • update checkout confirmation route to include order id
  • remove payment selection / forms
  • reduce checkout context complexity

@kevinxh kevinxh marked this pull request as ready for review March 21, 2023 23:20
@kevinxh kevinxh requested a review from a team as a code owner March 21, 2023 23:20
Copy link
Contributor

@vmarta vmarta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing the current behaviours vs the original one..

Copy link
Contributor

@vmarta vmarta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll continue reviewing the other files.


const CheckoutConfirmation = () => {
const {orderNo} = useParams()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's cool now the confirmation page is appending the order id to the url.

@@ -311,7 +311,7 @@ const Cart = () => {
return <CartSkeleton />
}

if (!isLoading && !basket?.productItems?.length) {
if (!basket?.productItems?.length) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we check loading here, we won't need to guard basket below

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loading is always false here since it is checked on line 310

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it is false, it indicates that basketData should be defined, we technically don't need to guard the basket here. Guarding is a good way to make sure things don't break, but if we know we have guarded other cases, we should not throw in the ? too much. 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, removed the guard

Copy link
Collaborator

@adamraya adamraya Mar 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexvuong @kevinxh FYI it looks the change broke the cart page when the cart is empty.
http://localhost:3000/global/en-GB/cart

TypeError: Cannot read properties of undefined (reading 'length')
    at Cart (http://localhost:3000/mobify/bundle/development/pages-cart.js:394:28)

This is a regression that was fixed in this PR: #1062

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok... i'm just gonna revert the change in cart.js.... it's out of scope for this PR and i thought it's a small diff improvement. but turns out to be too much hassle

}

const mockProducts = {
data: [
const mockOrder = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Can this mock data live elsewhere to keep the test file smaller? It's more than half the lines of the file!

@kevinxh kevinxh enabled auto-merge March 23, 2023 21:14
@kevinxh kevinxh added this pull request to the merge queue Mar 23, 2023
Merged via the queue into feature/integrate-commerce-sdk-react with commit b1ae9fc Mar 23, 2023
@kevinxh kevinxh deleted the checkout-payments branch March 23, 2023 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants