Skip to content

Commit 4fc3111

Browse files
author
Benjamin Klein
committed
vuestorefront#2810 fix using the wrong import; using store getters for orders history items
1 parent 02f7b48 commit 4fc3111

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

core/modules/order/components/UserOrders.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { mapGetters } from 'vuex';
12

23
/**
34
* Component responsible for displaying user orders. Requires User module.
@@ -6,13 +7,14 @@ export const UserOrders = {
67
name: 'UserOrders',
78
computed: {
89
ordersHistory () {
9-
return this.$store.state.user.orders_history.items
10+
return this.ordersHistoryItems()
1011
},
1112
isHistoryEmpty () {
12-
return this.$store.state.user.orders_history.items.length < 1
13+
return this.ordersHistoryItems().length < 1
1314
}
1415
},
1516
methods: {
17+
...mapGetters('user', ['ordersHistoryItems']),
1618
remakeOrder (products) {
1719
products.forEach(item => {
1820
this.$store.dispatch('product/single', { options: { sku: item.sku }, setCurrentProduct: false, selectDefaultVariant: false }).then((product) => {

core/modules/user/store/getters.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const getters: GetterTree<UserState, RootState> = {
99
isLocalDataLoaded: state => state.local_data_loaded,
1010
getUserToken (state) {
1111
return state.token
12+
},
13+
ordersHistoryItems (state) {
14+
return state.orders_history.items
1215
}
1316
}
1417

src/modules/order-history/components/UserOrders.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { isServer, bottomVisible } from '@vue-storefront/core/helpers'
2-
import MyOrder from '@vue-storefront/core/compatibility/components/blocks/MyAccount/MyOrder'
2+
import MyOrders from '@vue-storefront/core/compatibility/components/blocks/MyAccount/MyOrders'
3+
import { mapGetters } from 'vuex';
34

45
export default {
56
name: 'UserOrders',
6-
mixins: [MyOrder],
7+
mixins: [MyOrders],
78
data () {
89
return {
910
pagination: {
@@ -31,15 +32,11 @@ export default {
3132
},
3233
computed: {
3334
ordersHistory () {
34-
let items = []
35-
items = this.$store.state.user.orders_history.items
35+
let items = this.ordersHistoryItems()
3636
if (!isServer && this.lazyLoadOrdersOnscroll) {
3737
items = this.paginate(items, this.pagination.perPage, this.pagination.current)
3838
}
3939
return items
40-
},
41-
isHistoryEmpty () {
42-
return this.$store.state.user.orders_history.items.length < 1
4340
}
4441
},
4542
methods: {

0 commit comments

Comments
 (0)