-
Notifications
You must be signed in to change notification settings - Fork 63
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
feat: Trade Policies #1319
feat: Trade Policies #1319
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 5b67df2:
|
c54c725
to
1283240
Compare
Deployment failed with the following error:
|
const postalCode = String(oldSession.postalCode ?? '').replace(/\D/g, '') | ||
const country = oldSession.country ?? '' | ||
|
||
const [regionData, sessionData] = await Promise.all([ |
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.
Change promise.all to promise.allSettled
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.
why allSettled is better in this case @igorbrasileiro?
3c078ed
to
98d1ad4
Compare
98d1ad4
to
43b859c
Compare
43b859c
to
5b67df2
Compare
What's the purpose of this pull request?
This PR uses
VTEX Session
to add full support for trade policies on FastStoreHow it works?
We currently support a single trade policy by store on FastStore. You can configure your default trade policy at
store.config.js
.Supporting multiple sales channels means we are able to automatically detect and change the channel based on multiple parameters, like user and urls.
To make this auto detection possible, I made the
Session
context provider behave like theCart
provider. This means that it now accepts a new function calledonValidateSession
. This functions calls the backend to validate the session. The backend, then, changes/validates the session and updates values like channel, person, language, etc.On any change to the channel (because the user is logged in, for instance) the session is updated and the user starts browsing on this new session.
To make all work, I:
user
forperson
onSession
Context. Now person can be accessed bysession.person
person
query, since the person data is updated automatically on Session contextupdateSession
mutation in favor ofvalidateSession
How to test it?
Test1:
storeframework
tostorecomponents
yarn develop
/apparel---accessories
. Make sure the list of products appear/apparel---accessories?sc=2
. Make sure the product list changes.Test2:
storeframework
tostorecomponents
yarn develop
FASTSHOP TESTE HUB HML
?sc=2
. Make sure the currency changedStarters Deploy Preview
Future work
Requests for search api should wait for session validation. Currently these starters don't wait, causing possible flickering on the screen, since some products may appear and disappear (due to session being revalidated). Future work should include waiting for session validation before any requests.