diff --git a/CHANGELOG.md b/CHANGELOG.md index 11805d1b32..22cc643892 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed some potential mutations of Config object in `catalog` and `catalog-next` - @grimasod (#3843) - Set `null` as default value for custom option in product page - @gibkigonzo (#3885) - Fixed `config.storeViews.commonCache` being ignored - @grimasod (#3895) +- Fixed static pages, password notification, offline mode #3902 - @andrzejewsky (#3902) ### Changed / Improved - Changed pre commit hook to use NODE_ENV production to check for debugger statements - @resubaka (#3686) diff --git a/core/data-resolver/UserService.ts b/core/data-resolver/UserService.ts index c1e3a3b98e..afbf9691a6 100644 --- a/core/data-resolver/UserService.ts +++ b/core/data-resolver/UserService.ts @@ -42,15 +42,16 @@ const register = async (customer: DataResolver.Customer, password: string): Prom } }) -const updateProfile = async (userProfile: UserProfile): Promise => - TaskQueue.execute({ +const updateProfile = async (userProfile: UserProfile, actionName: string): Promise => + TaskQueue.queue({ url: processLocalizedURLAddress(config.users.me_endpoint), payload: { method: 'POST', headers: { 'Content-Type': 'application/json' }, mode: 'cors', body: JSON.stringify(userProfile) - } + }, + callback_event: `store:${actionName}` }) const getProfile = async () => diff --git a/core/data-resolver/types/DataResolver.d.ts b/core/data-resolver/types/DataResolver.d.ts index 349d8c9456..802da6ab28 100644 --- a/core/data-resolver/types/DataResolver.d.ts +++ b/core/data-resolver/types/DataResolver.d.ts @@ -40,7 +40,7 @@ declare namespace DataResolver { resetPassword: (email: string) => Promise, login: (username: string, password: string) => Promise, register: (customer: Customer, pssword: string) => Promise, - updateProfile: (userProfile: UserProfile) => Promise, + updateProfile: (userProfile: UserProfile, actionName: string) => Promise, getProfile: () => Promise, getOrdersHistory: (pageSize?: number, currentPage?: number) => Promise, changePassword: (passwordData: PasswordData) => Promise, diff --git a/core/modules/user/store/actions.ts b/core/modules/user/store/actions.ts index 070fda9c8e..6e5af68765 100644 --- a/core/modules/user/store/actions.ts +++ b/core/modules/user/store/actions.ts @@ -157,16 +157,17 @@ const actions: ActionTree = { /** * Update user profile with data from My Account page */ - async update ({ dispatch }, profile: UserProfile) { - const resp = await UserService.updateProfile(profile) - - if (resp.resultCode === 200) { + async update (_, profile: UserProfile) { + await UserService.updateProfile(profile, 'user/handleUpdateProfile') + }, + async handleUpdateProfile ({ dispatch }, event) { + if (event.resultCode === 200) { dispatch('notification/spawnNotification', { type: 'success', message: i18n.t('Account data has successfully been updated'), action1: { label: i18n.t('OK') } }, { root: true }) - dispatch('user/setCurrentUser', resp.result, { root: true }) + dispatch('user/setCurrentUser', event.result, { root: true }) } }, setCurrentUser ({ commit }, userData) { @@ -176,6 +177,16 @@ const actions: ActionTree = { * Change user password */ async changePassword ({ dispatch, getters }, passwordData) { + if (!onlineHelper.isOnline) { + dispatch('notification/spawnNotification', { + type: 'error', + message: i18n.t('Reset password feature does not work while offline!'), + action1: { label: i18n.t('OK') } + }, { root: true }) + + return + } + const resp = await UserService.changePassword(passwordData) if (resp.code === 200) { diff --git a/core/modules/user/test/unit/store/actions.spec.ts b/core/modules/user/test/unit/store/actions.spec.ts index 8ddc467c58..c1718ec3be 100644 --- a/core/modules/user/test/unit/store/actions.spec.ts +++ b/core/modules/user/test/unit/store/actions.spec.ts @@ -28,8 +28,11 @@ jest.mock('@vue-storefront/core/lib/multistore', () => ({ })) })); jest.mock('@vue-storefront/core/helpers', () => ({ - get isServer() { + get isServer () { return false + }, + onlineHelper: { + isOnline: true } })); jest.mock('@vue-storefront/core/lib/storage-manager', () => ({ @@ -304,14 +307,11 @@ describe('User actions', () => { resultCode: 200, result: 200 }; - (UserService.updateProfile as jest.Mock).mockImplementation(async () => - (responseOb) - ); const contextMock = { dispatch: jest.fn() } - await (userActions as any).update(contextMock, data.user) + await (userActions as any).handleUpdateProfile(contextMock, responseOb) expect(contextMock.dispatch).toHaveBeenCalledWith('user/setCurrentUser', responseOb.result, {root: true}) }) @@ -529,5 +529,4 @@ describe('User actions', () => { expect(contextMock.dispatch).toHaveBeenNthCalledWith(2, 'getOrdersHistory', {refresh, useCache}) }) }) - }) diff --git a/src/themes/default/components/core/ProductQuantity.vue b/src/themes/default/components/core/ProductQuantity.vue index baa3b33d3e..a9e463e1f7 100644 --- a/src/themes/default/components/core/ProductQuantity.vue +++ b/src/themes/default/components/core/ProductQuantity.vue @@ -4,7 +4,7 @@ :name="name" :value="value" :min="1" - :max="maxQuantity" + :max="max" :disabled="disabled" @input="$emit('input', $event)" @blur="$v.$touch()" @@ -60,6 +60,9 @@ export default { isOnline (value) { return onlineHelper.isOnline }, + max () { + return this.isOnline ? this.maxQuantity : null + }, disabled () { return this.isOnline ? !this.maxQuantity : false }, @@ -74,7 +77,7 @@ export default { return { value: { minValue: minValue(1), - maxValue: maxValue(this.maxQuantity) && !this.isSimpleOrConfigurable, + maxValue: maxValue(this.max) && !this.isSimpleOrConfigurable, numeric, required } diff --git a/src/themes/default/pages/Product.vue b/src/themes/default/pages/Product.vue index 4694bd4154..799a353213 100644 --- a/src/themes/default/pages/Product.vue +++ b/src/themes/default/pages/Product.vue @@ -36,26 +36,26 @@
- +
{{ getCurrentProduct.priceInclTax * getCurrentProduct.qty | price }}  + >{{ getCurrentProduct.price_incl_tax * getCurrentProduct.qty | price }}  {{ getCurrentProduct.original_price_incl_tax * getCurrentProduct.qty | price }}
- {{ getCurrentProduct.qty > 0 ? getCurrentProduct.priceInclTax * getCurrentProduct.qty : getCurrentProduct.priceInclTax | price }} + {{ getCurrentProduct.qty > 0 ? getCurrentProduct.price_incl_tax * getCurrentProduct.qty : getCurrentProduct.price_incl_tax | price }}
diff --git a/src/themes/default/pages/Static.vue b/src/themes/default/pages/Static.vue index a06a35d1ed..59e0855a2c 100644 --- a/src/themes/default/pages/Static.vue +++ b/src/themes/default/pages/Static.vue @@ -60,7 +60,7 @@ export default { }, computed: { activeComponent () { - const matchedNav = this.navigation.find(nav => nav.link === this.$route.path) + const matchedNav = this.navigation.find(nav => nav.link.includes(this.$route.path)) return matchedNav ? matchedNav.component : null } },