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

feat: Gets user's saved location if logged in and uses in session #2739

Open
wants to merge 9 commits into
base: feat/delivery-promise
Choose a base branch
from

Conversation

hellofanny
Copy link
Contributor

@hellofanny hellofanny commented Mar 21, 2025

What's the purpose of this pull request?

This PR implements the scenario where the user is logged in, and when the user's saved location (address and geo-coordinates) is available, it is saved in the current session.

Screenshot 2025-03-12 at 10 52 35

How it works?

  1. First we check if user is loggedIn
  2. If so, gets it's addresses
  3. Check for saved address (using the first of the list) postalCode and geoCoordinate, If available we update the current session with those information.

How to test it?

First, we will need to simulate user logged. (you can follow this docs steps with more detail or follow the steps below)

  1. Go to https://www.vtexfaststore.com/ and sign in, then copy the cookies: VtexIdclientAutCookie_storeframework, vtex_session and vtex_segment
  2. Running the store locally, paste those cookies.
  3. Update the indexDB you should be able to see person object with user's information (that was previously null)
  4. Now, refresh the page.
  5. if there is an address saved for this user, you should be able to see the postalCode and geoCoordinates in the session
image image

Starters Deploy Preview

vtex-sites/starter.store#731

Jira Task

Copy link

codesandbox-ci bot commented Mar 21, 2025

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.

@hellofanny hellofanny changed the title Feat/profile address location feat: Gets user's saved location if logged in and saves to session Mar 21, 2025
@hellofanny hellofanny changed the title feat: Gets user's saved location if logged in and saves to session feat: Gets user's saved location if logged in and uses in session Mar 21, 2025
@hellofanny hellofanny force-pushed the feat/profile-address-location branch from 884aac3 to 942ecf6 Compare March 21, 2025 15:30
@hellofanny hellofanny marked this pull request as ready for review March 21, 2025 15:40
@hellofanny hellofanny requested a review from a team as a code owner March 21, 2025 15:40
@hellofanny hellofanny requested review from eduardoformiga and lariciamota and removed request for a team March 21, 2025 15:40
@hellofanny hellofanny self-assigned this Mar 21, 2025
@hellofanny hellofanny requested a review from lucasfp13 March 21, 2025 15:42
Comment on lines 343 to 353
const addresses = await profile.addresses(userId)

function mapAddressesToList(AddressesObj: any): ProfileAddress[] {
if (!addresses || Object.keys(addresses).length === 0) {
return []
}

return Object.values<string>(AddressesObj).map(
(stringifiedObj) => JSON.parse(stringifiedObj) as ProfileAddress
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

question: addresses is already of type ProfileAddress[], I didn't get it why you considered as any at line 345. What is the shape of ProfileAddress[] incoming from API?

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