@viur/shop-components 0.0.1-dev.10
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/README.md +11 -0
- package/package.json +33 -0
- package/src/components/cart/CartNode.vue +0 -0
- package/src/components/cart/CartView.vue +693 -0
- package/src/components/cart/ConfirmView.vue +314 -0
- package/src/components/order/category/CategoryList.vue +83 -0
- package/src/components/order/category/CategoryView.vue +143 -0
- package/src/components/order/information/UserInfoMulti.vue +427 -0
- package/src/components/order/information/UserInformation.vue +332 -0
- package/src/components/order/information/adress/ShippingAdress.vue +143 -0
- package/src/components/order/item/ItemCard.vue +168 -0
- package/src/components/order/item/ItemView.vue +233 -0
- package/src/components/order/process/ExampleUsage.vue +100 -0
- package/src/components/order/process/OrderComplete.vue +41 -0
- package/src/components/order/process/OrderTabHeader.vue +7 -0
- package/src/components/order/process/OrderView.vue +210 -0
- package/src/router/index.js +103 -0
- package/src/stores/cart.js +126 -0
- package/src/views/ViewMissing.vue +20 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { reactive } from "vue";
|
|
2
|
+
import { Request, ListRequest } from "@viur/vue-utils";
|
|
3
|
+
import { defineStore } from "pinia";
|
|
4
|
+
import { ViURShopClient } from "@viur/viur-shop-client";
|
|
5
|
+
|
|
6
|
+
export const useCartStore = defineStore("cartstore", () => {
|
|
7
|
+
const shopClient = new ViURShopClient({
|
|
8
|
+
host_url:
|
|
9
|
+
window.location.origin === "http://localhost:8081"
|
|
10
|
+
? "http://localhost:8080"
|
|
11
|
+
: window.location.origin,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const state = reactive({
|
|
15
|
+
basketRootNode: {},
|
|
16
|
+
whishlistRootNodes: [],
|
|
17
|
+
children: {},
|
|
18
|
+
structure: { address: {}, cart: {} },
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
async function init() {
|
|
22
|
+
// ! initializes only children for cart of type basket
|
|
23
|
+
// ! for whishlists this has to be done in the component
|
|
24
|
+
await getRootNodes();
|
|
25
|
+
await getChildren(state.basketRootNode.key);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function getChildren(parentKey) {
|
|
29
|
+
let resp = await shopClient.cart_list({ cart_key: parentKey });
|
|
30
|
+
|
|
31
|
+
resp.forEach(async (child) => {
|
|
32
|
+
if (child.skel_type === "node") {
|
|
33
|
+
await getChildren(child.key);
|
|
34
|
+
} else {
|
|
35
|
+
if (!Object.keys(state.children).includes(child.key)) {
|
|
36
|
+
children[parentKey] = [];
|
|
37
|
+
}
|
|
38
|
+
children[parentKey].push(child);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function getRootNodes() {
|
|
44
|
+
let resp = await shopClient.cart_list();
|
|
45
|
+
|
|
46
|
+
resp.forEach((rootNode) => {
|
|
47
|
+
if (rootNode.is_root_node) {
|
|
48
|
+
if (rootNode.cart_type === "basket") {
|
|
49
|
+
state.basketRootNode = rootNode;
|
|
50
|
+
} else {
|
|
51
|
+
whishlistRootNodes.push(rootNode);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function addToCart(articleKey, cartKey) {
|
|
58
|
+
let resp = await shopClient.article_add({
|
|
59
|
+
article_key: articleKey,
|
|
60
|
+
parent_cart_key: cartKey,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
await updateCart(cartKey);
|
|
64
|
+
console.log("addToCart", resp); //TODO: Errorhandling as soon as shop module works again
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function getArticleView(articleKey, cartKey) {
|
|
68
|
+
let article = await shopClient.article_view({
|
|
69
|
+
article_key: articleKey,
|
|
70
|
+
parent_cart_key: cartKey,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
console.log("getArticleView", article); // ? Talk about necessarity
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function removeItem(articleKey, cartKey) {
|
|
77
|
+
let resp = await shopClient.article_remove({
|
|
78
|
+
article_key: articleKey,
|
|
79
|
+
parent_cart_key: cartKey,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
console.log("remove Resp", resp); //TODO: Errorhandling as soon as shop module works again
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function updateItem(articleKey, cartKey, quantity) {
|
|
86
|
+
let resp = await shopClient.article_update({
|
|
87
|
+
article_key: articleKey,
|
|
88
|
+
parent_cart_key: cartKey,
|
|
89
|
+
quantity: quantity,
|
|
90
|
+
quantity_mode: "replace",
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (quantity === 0) {
|
|
94
|
+
await updateCart(cartKey);
|
|
95
|
+
}
|
|
96
|
+
console.log("update Resp", resp); //TODO: Errorhandling as soon as shop module works again
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function updateCart(cartKey) {
|
|
100
|
+
await getChildren(cartKey);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function getAdressStructure() {
|
|
104
|
+
let addSkel = await shopClient.address_structure();
|
|
105
|
+
state.structure.address = addSkel.addSkel;
|
|
106
|
+
|
|
107
|
+
console.log("adress add", state.structure.address);
|
|
108
|
+
|
|
109
|
+
// Request.getStructure("shop.address").then(async (resp) => {
|
|
110
|
+
// let data = await resp.json();
|
|
111
|
+
// state.structure.address = data.addSkel;
|
|
112
|
+
|
|
113
|
+
// console.log("adress add", state.structure.address);
|
|
114
|
+
// });
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
state,
|
|
119
|
+
addToCart,
|
|
120
|
+
getArticleView,
|
|
121
|
+
removeItem,
|
|
122
|
+
updateItem,
|
|
123
|
+
init,
|
|
124
|
+
getAdressStructure,
|
|
125
|
+
};
|
|
126
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="home">View {{ route.path }} is missing.</div>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
import { defineComponent, reactive } from "vue"
|
|
7
|
+
import { useRoute } from "vue-router"
|
|
8
|
+
|
|
9
|
+
export default defineComponent({
|
|
10
|
+
props: {},
|
|
11
|
+
components: {},
|
|
12
|
+
setup(props, context) {
|
|
13
|
+
const route = useRoute()
|
|
14
|
+
const state = reactive({})
|
|
15
|
+
return { state, route }
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<style scoped></style>
|