SalesforceCommerceCloud / pwa-kit

React-based JavaScript frontend framework to create a progressive web app (PWA) storefront for Salesforce B2C Commerce.
https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/pwa-kit-overview.html
BSD 3-Clause "New" or "Revised" License
276 stars 124 forks source link

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

Open sdenadai opened 5 days ago

sdenadai commented 5 days ago

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 commented 5 days ago

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.

git2gus[bot] commented 5 days ago

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