Skip to content

Commit

Permalink
vuestorefront#2810 fix using the wrong import; using store getters fo…
Browse files Browse the repository at this point in the history
…r orders history items
  • Loading branch information
Benjamin Klein committed May 24, 2019
1 parent 02f7b48 commit 4fc3111
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 4 additions & 2 deletions core/modules/order/components/UserOrders.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { mapGetters } from 'vuex';

/**
* Component responsible for displaying user orders. Requires User module.
Expand All @@ -6,13 +7,14 @@ export const UserOrders = {
name: 'UserOrders',
computed: {
ordersHistory () {
return this.$store.state.user.orders_history.items
return this.ordersHistoryItems()
},
isHistoryEmpty () {
return this.$store.state.user.orders_history.items.length < 1
return this.ordersHistoryItems().length < 1
}
},
methods: {
...mapGetters('user', ['ordersHistoryItems']),
remakeOrder (products) {
products.forEach(item => {
this.$store.dispatch('product/single', { options: { sku: item.sku }, setCurrentProduct: false, selectDefaultVariant: false }).then((product) => {
Expand Down
3 changes: 3 additions & 0 deletions core/modules/user/store/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const getters: GetterTree<UserState, RootState> = {
isLocalDataLoaded: state => state.local_data_loaded,
getUserToken (state) {
return state.token
},
ordersHistoryItems (state) {
return state.orders_history.items
}
}

Expand Down
11 changes: 4 additions & 7 deletions src/modules/order-history/components/UserOrders.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { isServer, bottomVisible } from '@vue-storefront/core/helpers'
import MyOrder from '@vue-storefront/core/compatibility/components/blocks/MyAccount/MyOrder'
import MyOrders from '@vue-storefront/core/compatibility/components/blocks/MyAccount/MyOrders'
import { mapGetters } from 'vuex';

export default {
name: 'UserOrders',
mixins: [MyOrder],
mixins: [MyOrders],
data () {
return {
pagination: {
Expand Down Expand Up @@ -31,15 +32,11 @@ export default {
},
computed: {
ordersHistory () {
let items = []
items = this.$store.state.user.orders_history.items
let items = this.ordersHistoryItems()
if (!isServer && this.lazyLoadOrdersOnscroll) {
items = this.paginate(items, this.pagination.perPage, this.pagination.current)
}
return items
},
isHistoryEmpty () {
return this.$store.state.user.orders_history.items.length < 1
}
},
methods: {
Expand Down

0 comments on commit 4fc3111

Please sign in to comment.