@viur/shop-components 0.14.7 → 0.14.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viur/shop-components",
3
- "version": "0.14.7",
3
+ "version": "0.14.8",
4
4
  "description": "Frontend Vue components for the shop module of ViUR",
5
5
  "repository": {
6
6
  "type": "git",
@@ -5,7 +5,7 @@
5
5
  :nextfunction="nextStep"
6
6
  >
7
7
  </slot>
8
- <loading-handler :isLoading="cartState.isLoading" :isUpdating="cartState.isUpdating">
8
+ <loading-handler :isLoading="shopStore.state.cartIsLoading" :isUpdating="shopStore.state.cartIsLoading">
9
9
  <div class="viur-shop-item-wrapper" v-if="state.items.length>0">
10
10
  <cart-item v-for="item in state.items" :item="item"
11
11
  :edit="!shopStore.state.order?.['is_checkout_in_progress']"
@@ -85,7 +85,7 @@
85
85
 
86
86
 
87
87
  </sl-card>
88
- <div class="loading" v-if="cartState.isUpdating">
88
+ <div class="loading" v-if="shopStore.state.cartIsUpdating">
89
89
  <sl-spinner></sl-spinner>
90
90
  </div>
91
91
  </div>
@@ -96,7 +96,8 @@ import { getImage } from '../utils';
96
96
  import { useCart } from '../composables/cart';
97
97
  import dialogButton from './dialogButton.vue';
98
98
  import PriceBox from "./PriceBox.vue";
99
-
99
+ import { useViurShopStore } from "../shop";
100
+ const shopStore = useViurShopStore()
100
101
  const {addItem, removeItem, state:cartState, getValue} = useCart()
101
102
 
102
103
  const changeAmount = useDebounceFn((amount) => {
@@ -61,7 +61,7 @@
61
61
  <price-box :item="item" :amount="item.quantity" :retail="false"></price-box>
62
62
  </div>
63
63
  </sl-card>
64
- <div class="loading" v-if="cartState.isUpdating">
64
+ <div class="loading" v-if="shopStore.state.cartIsUpdating">
65
65
  <sl-spinner></sl-spinner>
66
66
  </div>
67
67
  </div>
@@ -72,7 +72,8 @@ import { getImage } from '../utils';
72
72
  import { useCart } from '../composables/cart';
73
73
  import dialogButton from './dialogButton.vue';
74
74
  import PriceBox from "./PriceBox.vue";
75
-
75
+ import { useViurShopStore } from "../shop";
76
+ const shopStore = useViurShopStore()
76
77
  const {addItem, removeItem, state:cartState, getValue} = useCart()
77
78
 
78
79
  const changeAmount = useDebounceFn((amount) => {
@@ -1,4 +1,4 @@
1
- import {computed, reactive} from 'vue';
1
+ import {computed, reactive, watch} from 'vue';
2
2
  import {Request} from '@viur/vue-utils'
3
3
  import { removeUndefinedValues} from '../utils'
4
4
 
@@ -7,8 +7,8 @@ import { useViurShopStore } from '../shop'
7
7
  export function useCart() {
8
8
  const shopStore = useViurShopStore()
9
9
  const state = reactive({
10
- isLoading:false,
11
- isUpdating:false
10
+ isLoading:computed(()=>shopStore.state.cartIsLoading), // not used anymore
11
+ isUpdating:computed(()=>shopStore.state.cartIsUpdating)// not used anymore
12
12
  })
13
13
 
14
14
  function getValue(value){
@@ -37,14 +37,13 @@ export function useCart() {
37
37
 
38
38
  function fetchCart() {
39
39
  //first fetch root then fetchItems for this root
40
- state.isLoading = true;
41
-
40
+ shopStore.state.cartIsLoading = true;
42
41
  if (shopStore.state.order != null && shopStore.state.order?.cart?.dest.key) {
43
42
  // shopStore.state.cartRoot = {};
44
43
  shopStore.state.cartRoot = shopStore.state.order.cart.dest;
45
44
 
46
45
  return fetchCartItems(shopStore.state.cartRoot["key"]).then(() => { // TODO: duplicate code
47
- state.isLoading = false;
46
+ shopStore.state.cartIsLoading = false;
48
47
  shopStore.state.cartReady = true;
49
48
  });
50
49
  }
@@ -52,7 +51,7 @@ export function useCart() {
52
51
  return fetchCartRoot().then(() => {
53
52
  if (!shopStore.state.cartRoot?.["key"]) return 0;
54
53
  fetchCartItems(shopStore.state.cartRoot["key"]).then(() => { // TODO: duplicate code
55
- state.isLoading = false;
54
+ shopStore.state.cartIsLoading = false;
56
55
  shopStore.state.cartReady = true;
57
56
  });
58
57
  });
@@ -136,25 +135,25 @@ export function useCart() {
136
135
 
137
136
  function addItem(key, quantity=1, cart=null, quantity_mode='replace'){
138
137
  //add Item to cart
139
- state.isUpdating = true
138
+ shopStore.state.cartIsUpdating = true
140
139
  return Request.post(`${shopStore.state.shopApiUrl}/article_add`, {dataObj:{
141
140
  article_key: key,
142
141
  parent_cart_key:cart?cart:shopStore.state.cartRoot['key'],
143
142
  quantity:quantity,
144
143
  quantity_mode:quantity_mode
145
144
  }}).then(async (resp)=>{
146
- state.isUpdating=false
145
+ shopStore.state.cartIsUpdating=false
147
146
  fetchCart()
148
147
  })
149
148
 
150
149
  }
151
150
  function removeItem(key, cart=null){
152
- state.isUpdating = true
151
+ shopStore.state.cartIsUpdating = true
153
152
  return Request.post(`${shopStore.state.shopApiUrl}/article_remove`, {dataObj:{
154
153
  article_key: key,
155
154
  parent_cart_key:cart?cart:shopStore.state.cartRoot['key']
156
155
  }}).then(async (resp)=>{
157
- state.isUpdating=false
156
+ shopStore.state.cartIsUpdating=false
158
157
  fetchCart()
159
158
  })
160
159
  }
package/src/shop.js CHANGED
@@ -103,7 +103,8 @@ export const useViurShopStore = defineStore("viurshopStore", () => {
103
103
  stepperLength:computed(()=>{
104
104
  return Object.keys(state.tabs).length
105
105
  }),
106
-
106
+ cartIsUpdating:false,
107
+ cartIsLoading:false,
107
108
  // SHOP DATA
108
109
  cartList:[], //articles in cart
109
110
  cartRoot:null, //actual cart rootnode entry ( used for shipping etc)