Skip to content

@W-17543565 implement update routes function#2280

Closed
hajinsuha1 wants to merge 5 commits intofeature/extensibility-v2from
W-17543565-implement-update-routes-function
Closed

@W-17543565 implement update routes function#2280
hajinsuha1 wants to merge 5 commits intofeature/extensibility-v2from
W-17543565-implement-update-routes-function

Conversation

@hajinsuha1
Copy link
Collaborator

@hajinsuha1 hajinsuha1 commented Feb 19, 2025

Description

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

  • test CATEGORY, PRODUCT, and CONTENT_ASSET resource returned by getUrlMapping API

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)

* is configured with, including those defined in the base application and those added by all the extensions. You can use this
* method to modify these routes in any way you want, but you must return an array of routes as a result.
*/
beforeRouteMatch(allRoutes: RouteProps[]): RouteProps[] {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@bendvc here is the bulk of the changes where I update the beforeRouteMatch to get the routes from window.__CONFIG__.app.routes if it's client side and allRoutes if it's server

// console.log('--- beforeRouteMatch in _routes.map:', path, 'componentName:', componentName, 'componentProps:', componentProps)
// TODO: Pass the components though the configuration
// - use a js file for configuration to import the files
const component = Pages[componentName]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

here is where we map the componentName to the actual component from extension-chakra-storefront/src/pages

beforeRouteMatch(allRoutes: RouteProps[]): RouteProps[] {
let configuredRoutes: RouteProps[] = []

const seoUrlMappingEnabled = true
Copy link
Contributor

Choose a reason for hiding this comment

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

@hajinsuha1 Hey Jinsu.. here are some high level general comments.

  1. My gut is telling me that any kind of logic for serializing/deserializing should be a SDK feature. This means the condition here would be somewhere inside the SDK code rather than in this extension.
  2. Should we entertain the idea making the routes.jsx and extendRoutes async? That might make our lives easier. We could also infer that if there is an asyn router that we must serialize.
  3. How do we get the page component map? I think we should be passing this to the extension via a configuration, we can then pass that value to the application component which will later use it when determining the route (we might have to flesh that out a little, but I'm making saying that this handling of serialized routes is also something that would be in the sdk)
  4. What should be in this extension is an hoc to is used in the extendApp function. That hoc should take advantage of the useBlock hook from the sdk with a special implementation that looks at the seo url mapping api.
  5. We want to make sure that this extension can accept a commerceAPI config. And also wraps the app with an optional provider like the store locator code is doing.
  6. The custom code that makes an api called to get the seo mapping should also happen in extendRoutes, I don't thing beforeRouteMatch is the correct tie in point.

@hajinsuha1 hajinsuha1 closed this Mar 5, 2025
@hajinsuha1 hajinsuha1 deleted the W-17543565-implement-update-routes-function branch March 5, 2025 14:22
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.

2 participants