@shopbite-de/storefront 1.2.6 → 1.2.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.
|
@@ -94,6 +94,7 @@ const { data: productDetails, pending } = useAsyncData(
|
|
|
94
94
|
const {
|
|
95
95
|
selectedProduct,
|
|
96
96
|
selectedQuantity,
|
|
97
|
+
isLoading,
|
|
97
98
|
addToCart,
|
|
98
99
|
setSelectedProduct,
|
|
99
100
|
setSelectedExtras,
|
|
@@ -157,6 +158,7 @@ const emit = defineEmits(["product-added"]);
|
|
|
157
158
|
:max="100"
|
|
158
159
|
/>
|
|
159
160
|
<UButton
|
|
161
|
+
:disabled="isLoading"
|
|
160
162
|
size="xl"
|
|
161
163
|
label="In den Warenkorb"
|
|
162
164
|
icon="i-lucide-shopping-cart"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Schemas, operations } from "#shopware";
|
|
2
2
|
import type { AssociationItemProduct } from "~/types/Association";
|
|
3
|
-
import { v5 as uuidv5 } from "uuid";
|
|
3
|
+
import { v5 as uuidv5, v4 as uuidv4 } from "uuid";
|
|
4
4
|
import { computed, ref } from "vue";
|
|
5
5
|
|
|
6
6
|
const UUID_NAMESPACE = "b098ef7e-0fa2-4073-b002-7ceec4360fbf";
|
|
@@ -17,6 +17,7 @@ export function useAddToCart() {
|
|
|
17
17
|
const deselectedIngredients = ref<string[]>([]);
|
|
18
18
|
const selectedQuantity = ref(1);
|
|
19
19
|
const selectedProduct = ref<Schemas["Product"] | null>(null);
|
|
20
|
+
const isLoading = ref(false);
|
|
20
21
|
|
|
21
22
|
const cartItemLabel = computed(() => {
|
|
22
23
|
if (!selectedProduct.value) return "";
|
|
@@ -75,23 +76,23 @@ export function useAddToCart() {
|
|
|
75
76
|
|
|
76
77
|
const extras = createExtras();
|
|
77
78
|
|
|
79
|
+
// Container product when extras are selected
|
|
80
|
+
const generatedUuid = uuidv5(
|
|
81
|
+
generateProductId(selectedProduct.value.id, selectedExtras.value),
|
|
82
|
+
UUID_NAMESPACE,
|
|
83
|
+
);
|
|
84
|
+
|
|
78
85
|
// Simple product when no extras
|
|
79
86
|
if (extras.length === 0 && deselectedIngredients.value.length === 0) {
|
|
80
87
|
return [
|
|
81
88
|
{
|
|
89
|
+
id: selectedProduct.value.id,
|
|
82
90
|
quantity: selectedQuantity.value,
|
|
83
91
|
type: LINE_ITEM_PRODUCT,
|
|
84
|
-
referencedId: selectedProduct.value.id,
|
|
85
92
|
},
|
|
86
93
|
];
|
|
87
94
|
}
|
|
88
95
|
|
|
89
|
-
// Container product when extras are selected
|
|
90
|
-
const generatedUuid = uuidv5(
|
|
91
|
-
generateProductId(selectedProduct.value.id, selectedExtras.value),
|
|
92
|
-
UUID_NAMESPACE,
|
|
93
|
-
);
|
|
94
|
-
|
|
95
96
|
return [
|
|
96
97
|
{
|
|
97
98
|
id: generatedUuid,
|
|
@@ -103,9 +104,10 @@ export function useAddToCart() {
|
|
|
103
104
|
},
|
|
104
105
|
children: [
|
|
105
106
|
{
|
|
106
|
-
id:
|
|
107
|
+
id: uuidv4().replaceAll("-", ""),
|
|
107
108
|
quantity: selectedQuantity.value,
|
|
108
109
|
type: LINE_ITEM_PRODUCT,
|
|
110
|
+
referencedId: selectedProduct.value.id,
|
|
109
111
|
},
|
|
110
112
|
...extras,
|
|
111
113
|
],
|
|
@@ -128,6 +130,7 @@ export function useAddToCart() {
|
|
|
128
130
|
|
|
129
131
|
async function addToCart(onSuccess?: () => void) {
|
|
130
132
|
if (!selectedProduct.value) return;
|
|
133
|
+
isLoading.value = true;
|
|
131
134
|
|
|
132
135
|
const cartItems = createCartItems();
|
|
133
136
|
const newCart = await addProducts(cartItems);
|
|
@@ -143,6 +146,7 @@ export function useAddToCart() {
|
|
|
143
146
|
},
|
|
144
147
|
});
|
|
145
148
|
|
|
149
|
+
isLoading.value = false;
|
|
146
150
|
if (onSuccess) {
|
|
147
151
|
onSuccess();
|
|
148
152
|
}
|
|
@@ -166,6 +170,7 @@ export function useAddToCart() {
|
|
|
166
170
|
deselectedIngredients,
|
|
167
171
|
selectedQuantity,
|
|
168
172
|
cartItemLabel,
|
|
173
|
+
isLoading,
|
|
169
174
|
addToCart,
|
|
170
175
|
setSelectedProduct,
|
|
171
176
|
setSelectedExtras,
|
package/app/pages/c/[...all].vue
CHANGED
|
@@ -9,7 +9,7 @@ const { resolvePath } = useNavigationSearch();
|
|
|
9
9
|
const route = useRoute();
|
|
10
10
|
const routePath = route.path;
|
|
11
11
|
|
|
12
|
-
const { data: seoResult } = await useAsyncData(
|
|
12
|
+
const { data: seoResult, error } = await useAsyncData(
|
|
13
13
|
`cmsResponse${routePath}`,
|
|
14
14
|
async () => {
|
|
15
15
|
// For client links if the history state contains seo url information we can omit the api call
|
|
@@ -22,17 +22,20 @@ const { data: seoResult } = await useAsyncData(
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
const seoUrl = await resolvePath(routePath);
|
|
25
|
+
|
|
26
|
+
if (!seoUrl?.foreignKey) {
|
|
27
|
+
throw createError({
|
|
28
|
+
statusCode: 404,
|
|
29
|
+
statusMessage: `No data fetched from API for ${routePath}`,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
25
33
|
return seoUrl;
|
|
26
34
|
},
|
|
27
35
|
);
|
|
28
36
|
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
throw createError({
|
|
33
|
-
statusCode: 404,
|
|
34
|
-
statusMessage: `No data fetched from API for ${routePath}`,
|
|
35
|
-
});
|
|
37
|
+
if (error.value) {
|
|
38
|
+
throw error.value;
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
const { foreignKey } = useNavigationContext(
|