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

[nextjs] Add support for fallback point of sale #1367

Merged
merged 6 commits into from
Mar 8, 2023

Conversation

art-alexeyenko
Copy link
Contributor

Description / Motivation

Point of sale values retrieved from Sitecore side can have a fallback entry with a wildcard key. This PR ensures JSS can use it when needed.

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@art-alexeyenko art-alexeyenko requested a review from a team March 7, 2023 13:22
Copy link
Contributor

@addy-pathania addy-pathania left a comment

Choose a reason for hiding this comment

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

Looks good. See one comment.

packages/sitecore-jss-nextjs/src/utils.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@illiakovalenko illiakovalenko left a comment

Choose a reason for hiding this comment

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

Can we introduce PosResolver as it was before, similar to SiteResolver? Because now it's not standardized

const pointOfSale = site.pointOfSale
? site.pointOfSale[language] || site.pointOfSale[site.language]
: '';
const pointOfSale = resolvePointOfSale(site, language);
Copy link
Contributor

Choose a reason for hiding this comment

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

If we have POS resolver, in this case, it needs to be customizable, so can be provided in config

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SiteResolver is more complex than PosResolver needs to be. I believe it's better to keep point of sale resolution simple, but separate, so that it can be easily changed if the point of sale data format changes in future.
But yes, we need to have a way to override resolution in middleware.

@art-alexeyenko art-alexeyenko requested a review from ambrauer March 8, 2023 16:31
packages/sitecore-jss-nextjs/src/utils.ts Outdated Show resolved Hide resolved
Comment on lines 53 to 54
// you can also pass a custom point of sale resolver into middleware
// resolvePointOfSale: (site, language) => { ... }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should have this wired up to use the PosResolver.resolve here to make it more explicit (and match usage in CdpPageView.tsx). If possible, keep the old comments (maybe even function name?)

Suggested change
// you can also pass a custom point of sale resolver into middleware
// resolvePointOfSale: (site, language) => { ... }
// This function resolves point of sale for cdp calls.
// Point of sale may differ by locale and middleware will use request language to get the correct value every time it's invoked
getPointOfSale: PosResolver.resolve,

@art-alexeyenko art-alexeyenko requested a review from ambrauer March 8, 2023 20:11
Copy link
Contributor

@ambrauer ambrauer left a comment

Choose a reason for hiding this comment

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

Looks great!

@ambrauer ambrauer merged commit de6d338 into dev Mar 8, 2023
@ambrauer ambrauer deleted the feature/pointofsale-fallback branch March 8, 2023 20:26
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.

4 participants