Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions core/data-resolver/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ const register = async (customer: DataResolver.Customer, password: string): Prom
}
})

const updateProfile = async (userProfile: UserProfile): Promise<Task> =>
TaskQueue.execute({
const updateProfile = async (userProfile: UserProfile, actionName: string): Promise<any> =>
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 () =>
Expand Down
2 changes: 1 addition & 1 deletion core/data-resolver/types/DataResolver.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ declare namespace DataResolver {
resetPassword: (email: string) => Promise<Task>,
login: (username: string, password: string) => Promise<Task>,
register: (customer: Customer, pssword: string) => Promise<Task>,
updateProfile: (userProfile: UserProfile) => Promise<Task>,
updateProfile: (userProfile: UserProfile, actionName: string) => Promise<Task>,
getProfile: () => Promise<Task>,
getOrdersHistory: (pageSize?: number, currentPage?: number) => Promise<Task>,
changePassword: (passwordData: PasswordData) => Promise<Task>,
Expand Down
21 changes: 16 additions & 5 deletions core/modules/user/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,17 @@ const actions: ActionTree<UserState, RootState> = {
/**
* 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) {
Expand All @@ -176,6 +177,16 @@ const actions: ActionTree<UserState, RootState> = {
* 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) {
Expand Down
11 changes: 5 additions & 6 deletions core/modules/user/test/unit/store/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => ({
Expand Down Expand Up @@ -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})
})
Expand Down Expand Up @@ -529,5 +529,4 @@ describe('User actions', () => {
expect(contextMock.dispatch).toHaveBeenNthCalledWith(2, 'getOrdersHistory', {refresh, useCache})
})
})

})
7 changes: 5 additions & 2 deletions src/themes/default/components/core/ProductQuantity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:name="name"
:value="value"
:min="1"
:max="maxQuantity"
:max="max"
:disabled="disabled"
@input="$emit('input', $event)"
@blur="$v.$touch()"
Expand Down Expand Up @@ -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
},
Expand All @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions src/themes/default/pages/Product.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@
</div>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<meta itemprop="priceCurrency" :content="$store.state.storeView.i18n.currencyCode">
<meta itemprop="price" :content="parseFloat(getCurrentProduct.priceInclTax).toFixed(2)">
<meta itemprop="price" :content="parseFloat(getCurrentProduct.price_incl_tax).toFixed(2)">
<meta itemprop="availability" :content="structuredData.availability">
<meta itemprop="url" :content="getCurrentProduct.url_path">
<div class="mb40 price serif" v-if="getCurrentProduct.type_id !== 'grouped'">
<div
class="h3 cl-secondary"
v-if="getCurrentProduct.special_price && getCurrentProduct.priceInclTax && getCurrentProduct.original_price_incl_tax"
v-if="getCurrentProduct.special_price && getCurrentProduct.price_incl_tax && getCurrentProduct.original_price_incl_tax"
>
<span
class="h2 cl-mine-shaft weight-700"
>{{ getCurrentProduct.priceInclTax * getCurrentProduct.qty | price }}</span>&nbsp;
>{{ getCurrentProduct.price_incl_tax * getCurrentProduct.qty | price }}</span>&nbsp;
<span
class="price-original h3"
>{{ getCurrentProduct.original_price_incl_tax * getCurrentProduct.qty | price }}</span>
</div>
<div
class="h2 cl-mine-shaft weight-700"
v-if="!getCurrentProduct.special_price && getCurrentProduct.priceInclTax"
v-if="!getCurrentProduct.special_price && getCurrentProduct.price_incl_tax"
>
{{ getCurrentProduct.qty > 0 ? getCurrentProduct.priceInclTax * getCurrentProduct.qty : getCurrentProduct.priceInclTax | price }}
{{ getCurrentProduct.qty > 0 ? getCurrentProduct.price_incl_tax * getCurrentProduct.qty : getCurrentProduct.price_incl_tax | price }}
</div>
</div>
<div class="cl-primary variants" v-if="getCurrentProduct.type_id =='configurable'">
Expand Down
2 changes: 1 addition & 1 deletion src/themes/default/pages/Static.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
},
Expand Down