vuestorefront / vue-storefront

Alokai is a Frontend as a Service solution that simplifies composable commerce. It connects all the technologies needed to build and deploy fast & scalable ecommerce frontends. It guides merchants to deliver exceptional customer experiences quickly and easily.
https://www.alokai.com
MIT License
10.6k stars 2.08k forks source link

[Bug] [Next] My account - impossible to change data #4499

Closed akrajna closed 3 years ago

akrajna commented 4 years ago

Current behavior

It is impossible to change data in 'My profile' and 'Shipping' sections in 'my account'. Changes made are not saved.

Expected behavior

It should be possible to change data in 'My profile' and 'Shipping' sections in 'my account'. Changes should be saved.

Steps to reproduce the issue

initial condition: user is logged in

  1. go to 'My account'
  2. click on 'My profile'
  3. change First name
  4. click 'update personal data' button
  5. click on 'Shipping details'
  6. click on 'change' button next to any address
  7. change street name
  8. click 'update the addresses' button
  9. click on ' My profile' - check the data
  10. click on 'Shipping details' - check the data

EditMyaccount

related to the issue: https://github.com/DivanteLtd/vsf-pro/issues/34

Repository

Next - https://lovecrafts-demo.storefrontcloud.io/

Can you handle fixing this bug by yourself?

Which Release Cycle state this refers to? Info for developer.

Pick one option.

Environment details

Additional information

AddyAhmed commented 3 years ago

Hi @akrajna

I faced the same problem, a fix is available for the "update personal data" which can be found below

Bug: https://github.com/DivanteLtd/vsf-capybara/issues/510 Fix: https://github.com/DivanteLtd/vsf-capybara/commit/bac3e5ea6e74c4cba470486407dc0ea3520173fd

To get the shipping details working, you will need to implement a similar fix to components/organisms/o-my-account-shipping-details.vue

Add the following imports

import config from 'config';
import pick from 'lodash-es/pick';

Update line 247

from

let userDataToUpdate = this.$store.state.user.current;

to

let userDataToUpdate = pick(this.$store.state.user.current, config.users.allowModification);

Ensure allowModification is present under "users" in the config/default.json

"users": {
    "autoRefreshTokens": true,
    "loginAfterCreatePassword": true,
    "endpoint": "/api/user",
    "history_endpoint": "/api/user/order-history?token={{token}}&pageSize={{pageSize}}&currentPage={{currentPage}}",
    "resetPassword_endpoint": "/api/user/reset-password",
    "createPassword_endpoint": "/api/user/create-password",
    "changePassword_endpoint": "/api/user/change-password?token={{token}}",
    "login_endpoint": "/api/user/login",
    "create_endpoint": "/api/user/create",
    "me_endpoint": "/api/user/me?token={{token}}",
    "refresh_endpoint": "/api/user/refresh",
    "allowModification": ["firstname", "lastname", "email", "addresses"]
  }

The fix only sets the required customer details, in this case firstname, lastname, email and address. Previously it was sending the entire customer data, causing the API to throw an error and return a 500.

AddyAhmed commented 3 years ago

The delete address has the same issue

The fix in my previous comment needs to be appleid to the method deleteAddress in the same file components/organisms/o-my-account-shipping-details.vue

Update

let userDataToUpdate = this.$store.state.user.current;

to

let userDataToUpdate = pick(this.$store.state.user.current, config.users.allowModification);

Fifciu commented 3 years ago

For VSF Next - @filipsobol is working on that right now For VSF1 x Capybara - @AdamPawlinski will handle issues with updating & removing shipping details - thanks for useful snippets @AddyAhmed

filipsobol commented 3 years ago

VSF Next now supports updating My Account data.