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

@W-14901147: Shopper SEO hook #1688

Merged
merged 8 commits into from
Mar 11, 2024
Merged

@W-14901147: Shopper SEO hook #1688

merged 8 commits into from
Mar 11, 2024

Conversation

alexvuong
Copy link
Collaborator

Description

This PR added query hooks for Shopper SEO APIs that has been added into commerce-sdk-isomorphic v1.12.0

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

Changes

  • (change1)

How to Test-Drive This PR

For testing purpose of this API, I've added redirects in BM that will used in the template Home page.

Source: /sample-product
Destination: /sample-product-redirected

  • check out code
  • npm ci at root
  • npm start to start up Retail app
  • Navigate to home page http://localhost:3000. Confirm that Shopper SEO useUrlMapping returns the data in the browser console
{
  copySourceParams: false,
  destinationUrl: '/sample-product-redirected',
  statusCode: '301'
}

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

@alexvuong alexvuong requested a review from a team as a code owner March 6, 2024 00:38
vmarta
vmarta previously approved these changes Mar 8, 2024
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.

+1 from me. Had a question though about showing example usage.

And as an aside: maybe it's just me.. I found the code not really readable 😅 Maybe it's because of the typing. Perhaps the library is also really doing complex things.. 🤷 But anyways, other files are already coded in a similar way.

Comment on lines 77 to 83
//TODO: Remove after PR is approved. This is for hook testing and verifying
const {data} = useUrlMapping({
parameters: {
urlSegment: '/sample-product'
}
})
console.log('data', data)
Copy link
Contributor

Choose a reason for hiding this comment

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

After this test code is removed, will the retail-react-app show an example of how to really use useUrlMapping?

For example, right now I don't know whether I'll need to update my routes. Where should I call useUrlMapping?

I think it would be good if we can leave commented code somewhere, as a best practice on how to use this url mapping feature.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@vmarta I think useUrlMapping is like any other query hooks in the library. You can certainly call it any where you want in the app as long as you know which parameters to pass in the hook. (we currently do not have any examples for unused hooks in commerce-react)
In addition, we will start the Support ShopperSEO url mapping work soon, I think we will have more context to document there.

@alexvuong alexvuong merged commit b47713f into develop Mar 11, 2024
28 checks passed
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.

None yet

3 participants