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

[BUG] Profile edit deletes addreses from useCurrentCustomer response #1872

Closed
sdenadai opened this issue Jul 2, 2024 · 2 comments
Closed
Labels
USER STORY git2Gus label

Comments

@sdenadai
Copy link

sdenadai commented Jul 2, 2024

Summary

Opening the Account page, a request with the useCurrentCustomer hook is made.
The response contains an addresses key with the user addresses.

If you edit the profile (for example changing the first name), and press save, the mutation called with useShopperCustomersMutation('updateCustomer') overwrites the response of the useCurrentCustomer deleting the addresses key.

Doing so, if you go to the Addesses section of the user account page you don't see any addresses. Still, they reappear if you force a page reload performing a fresh useCurrentCustomer call.

Steps To Reproduce

This issue can easily be seen on the official pwa-kit demo (https://pwa-kit.mobify-storefront.com/).

  1. Open the PWA Kit demo website
  2. Register a new account (or login if you already have one)
  3. In the account page, head to the Addresses section and add an address if you don't already have one
  4. In the account page, back to the Account Details* section, click the "Edit" in the My Profile card, change something like the first name and press Save
  5. Now click the Addesses section in the sidebar
  6. You will see the No Saved Addresses block.
  7. Reloading the page will perform a fresh request loading the addresses again.

Expected result

Editing the user profile shouldn't remove necessary account data from the response

Actual result

The cached useCurrentCustomer response (seen from the React Tanstack Query Debug tool) loses the addresses key after saving the user profile.

System Information (as applicable)

Browser: Google Chrome
Node version: 18.15.0
pwa-kit version: Tested on 3.1.0 and 3.6.0
Desktop OS: macOS
Mobile Device Info: -

@bendvc
Copy link
Collaborator

bendvc commented Jul 2, 2024

Thank you @sdenadai for reporting this. I can confirm that this is an issue after following your steps to reproduce. I'm going to tag this issue so it makes its way into our ticketing system.

In the meantime, a simple work around would be to re-fetch that customer information with the addresses using the "useCurrentCustomer" hook.

@bendvc bendvc added the USER STORY git2Gus label label Jul 2, 2024
Copy link

git2gus bot commented Jul 2, 2024

This issue has been linked to a new work item: W-16151037

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
USER STORY git2Gus label
2 participants