@viur/shop-components 0.14.7 → 0.14.9
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
package/src/Steps/ShopCart.vue
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
:nextfunction="nextStep"
|
|
6
6
|
>
|
|
7
7
|
</slot>
|
|
8
|
-
<loading-handler :isLoading="
|
|
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="
|
|
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="
|
|
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) => {
|
|
@@ -69,14 +69,14 @@ function removeDiscountAction(key){
|
|
|
69
69
|
removeDiscount(key)
|
|
70
70
|
.then(async (resp) => {
|
|
71
71
|
state.loading=false
|
|
72
|
-
state.alert.msg =
|
|
72
|
+
state.alert.msg = i18n.t('viur.shop.discount_removed');
|
|
73
73
|
state.alert.show = true;
|
|
74
74
|
state.alert.variant = "success";
|
|
75
75
|
})
|
|
76
76
|
.catch((error) => {
|
|
77
77
|
state.loading=false
|
|
78
78
|
console.log("error bei rabatt", error);
|
|
79
|
-
state.alert.msg =
|
|
79
|
+
state.alert.msg = i18n.t('viur.shop.discount_not_found');
|
|
80
80
|
state.alert.show = true;
|
|
81
81
|
state.alert.variant = "danger";
|
|
82
82
|
});
|
package/src/composables/cart.js
CHANGED
|
@@ -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:
|
|
11
|
-
isUpdating:
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
145
|
+
shopStore.state.cartIsUpdating=false
|
|
147
146
|
fetchCart()
|
|
148
147
|
})
|
|
149
148
|
|
|
150
149
|
}
|
|
151
150
|
function removeItem(key, cart=null){
|
|
152
|
-
state.
|
|
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.
|
|
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)
|