@viur/shop-components 0.0.1-dev.60 → 0.0.1-dev.61
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/old/client/HttpClient.js +111 -0
- package/old/client/ViURShopClient.js +472 -0
- package/old/client/index.js +23 -0
- package/old/client/types.js +10 -0
- package/old/components/ExampleUsage.vue +95 -0
- package/old/components/ShopCart.vue +91 -0
- package/old/components/ShopOrderConfirm.vue +311 -0
- package/{src → old}/components/ShopOrderStepper.vue +111 -23
- package/old/components/ShopPaymentProvider.vue +113 -0
- package/old/components/ShopShippingMethod.vue +52 -0
- package/{src/components/ui → old/components}/ShopSummary.vue +28 -35
- package/{src → old}/components/ShopUserData.vue +51 -65
- package/{src → old}/components/cart/CartLeafModel.vue +24 -16
- package/{src → old}/components/cart/CartNode.vue +1 -0
- package/{src → old}/components/cart/CartTree.vue +13 -0
- package/old/components/cart/CartView.vue +82 -0
- package/{src → old}/components/cart/Discount.vue +8 -8
- package/old/components/generic/loadinghandler.vue +76 -0
- package/old/components/paymentProvider/prepayment.vue +0 -0
- package/old/components/paymentProvider/unzerPayment.vue +140 -0
- package/old/components/simple/ShopUserData.vue +161 -0
- package/old/components/simple/SimpleDefaultLayout.vue +116 -0
- package/old/components/ui/generic/CardSelector.vue +52 -0
- package/old/components/ui/generic/CartList.vue +69 -0
- package/old/components/ui/generic/ShippingInfo.vue +56 -0
- package/old/components/ui/generic/alerts/ShopAlert.vue +30 -0
- package/old/components/ui/payment/PaymentOption.vue +79 -0
- package/old/components/ui/payment/PaymentSelector.vue +158 -0
- package/old/components/ui/stepper/StepperItem.vue +90 -0
- package/{src → old}/components/ui/stepper/StepperTab.vue +30 -2
- package/old/components/ui/stepper/StepperTrigger.vue +69 -0
- package/old/components/ui/userdata/AddForm.vue +160 -0
- package/old/components/ui/userdata/AddressBox.vue +137 -0
- package/{src → old}/components/ui/userdata/BaseLayout.vue +15 -32
- package/old/stores/address.js +122 -0
- package/old/stores/cart.js +266 -0
- package/old/stores/message.js +21 -0
- package/old/stores/order.js +202 -0
- package/old/stores/payment.js +79 -0
- package/old/stores/shipping.js +78 -0
- package/package.json +3 -5
- package/src/Shop.vue +212 -0
- package/src/ShopOrderStepper.vue +89 -0
- package/src/ShopSummary.vue +170 -0
- package/src/Steps/ShopCart.vue +60 -0
- package/src/Steps/ShopOrderComplete.vue +24 -0
- package/src/Steps/ShopOrderConfirm.vue +295 -0
- package/src/Steps/ShopPaymentProvider.vue +53 -0
- package/src/Steps/ShopShippingMethod.vue +53 -0
- package/src/Steps/ShopUserDataGuest.vue +78 -0
- package/src/Steps/index.js +15 -0
- package/src/components/AddressForm.vue +84 -0
- package/src/components/AddressFormLayout.vue +107 -0
- package/src/components/CardSelector.vue +68 -0
- package/src/components/CartItem.vue +325 -0
- package/src/components/CartItemSmall.vue +257 -0
- package/src/components/LoadingHandler.vue +76 -0
- package/src/components/PaymentOption.vue +78 -0
- package/src/components/PaymentProviderUnzer.vue +201 -0
- package/src/components/PaymentSelector.vue +55 -0
- package/src/components/ShopAlert.vue +30 -0
- package/src/components/StepperTab.vue +132 -0
- package/src/components/dialogButton.vue +49 -0
- package/src/composables/address.js +95 -0
- package/src/composables/cart.js +132 -0
- package/src/composables/order.js +80 -0
- package/src/composables/payment.js +75 -0
- package/src/composables/shipping.js +32 -0
- package/src/main.js +32 -38
- package/src/shop.js +251 -0
- package/src/translations/de.js +15 -0
- package/src/translations/en.js +5 -0
- package/src/utils.js +49 -0
- package/vite.config.js +0 -2
- package/src/components/ShopCart.vue +0 -512
- package/src/components/ShopOrderConfirm.vue +0 -291
- package/src/components/cart/CartView.vue +0 -723
- package/src/components/order/OrderSidebar.vue +0 -102
- package/src/components/order/category/CategoryList.vue +0 -83
- package/src/components/order/category/CategoryView.vue +0 -143
- package/src/components/order/information/adress/ShippingAdress.vue +0 -143
- package/src/components/order/item/ItemCard.vue +0 -168
- package/src/components/order/item/ItemView.vue +0 -232
- package/src/components/order/process/ConfirmView.vue +0 -312
- package/src/components/order/process/ExampleUsage.vue +0 -113
- package/src/components/order/process/OrderTabHeader.vue +0 -16
- package/src/components/order/process/SelectPaymentProvider.vue +0 -62
- package/src/components/order/process/Shipping.vue +0 -46
- package/src/components/ui/generic/ArticleList.vue +0 -222
- package/src/components/ui/generic/ExamplePagination.vue +0 -236
- package/src/components/ui/generic/alerts/ShopAlert.vue +0 -19
- package/src/components/ui/generic/makeData.js +0 -39
- package/src/components/ui/stepper/StepperItem.vue +0 -39
- package/src/components/ui/stepper/StepperTrigger.vue +0 -35
- package/src/components/ui/userdata/AddForm.vue +0 -125
- package/src/components/ui/userdata/AddressBox.vue +0 -117
- package/src/router/index.js +0 -103
- package/src/stores/cart.js +0 -336
- package/src/views/ViewMissing.vue +0 -20
- /package/{src → old}/components/ShopOrderComplete.vue +0 -0
- /package/{src → old}/components/cart/CartLeaf.vue +0 -0
- /package/{src → old}/components/cart/CartTreeWrapper.vue +0 -0
- /package/{src/components/lib/utils.js → old/components/paymentProvider/paypalplus.vue} +0 -0
- /package/{src → old}/components/ui/generic/ShopPriceFormatter.vue +0 -0
- /package/{src → old}/components/ui/userdata/CustomBooleanBone.vue +0 -0
- /package/{src → old}/components/ui/userdata/CustomSelectBone.vue +0 -0
- /package/{src → old}/components/ui/userdata/CustomStringBone.vue +0 -0
- /package/{src → old}/components/ui/userdata/DefaultLayout.vue +0 -0
- /package/{src → old}/components/ui/userdata/SelectAddress.vue +0 -0
- /package/{src → old}/components/ui/userdata/multi/ActionBar.vue +0 -0
- /package/{src → old}/components/ui/userdata/multi/CartSelection.vue +0 -0
- /package/{src/style → old}/ignite/.editorconfig +0 -0
- /package/{src/style → old}/ignite/.github/workflows/ignite.yml +0 -0
- /package/{src/style → old}/ignite/.github/workflows/node.yml +0 -0
- /package/{src/style → old}/ignite/.postcssrc.cjs +0 -0
- /package/{src/style → old}/ignite/CHANGELOG.md +0 -0
- /package/{src/style → old}/ignite/LICENSE +0 -0
- /package/{src/style → old}/ignite/README.md +0 -0
- /package/{src/style → old}/ignite/dist/ignite.css +0 -0
- /package/{src/style → old}/ignite/dist/ignite.min.css +0 -0
- /package/{src/style → old}/ignite/foundation/basic.css +0 -0
- /package/{src/style → old}/ignite/foundation/color.css +0 -0
- /package/{src/style → old}/ignite/foundation/config.css +0 -0
- /package/{src/style → old}/ignite/foundation/grid.css +0 -0
- /package/{src/style → old}/ignite/foundation/mediaqueries.css +0 -0
- /package/{src/style → old}/ignite/foundation/reset.css +0 -0
- /package/{src/style → old}/ignite/ignite.css +0 -0
- /package/{src/style → old}/ignite/ignite.css.map +0 -0
- /package/{src/style → old}/ignite/package-lock.json +0 -0
- /package/{src/style → old}/ignite/package.json +0 -0
- /package/{src/style → old}/ignite/shoelace.css +0 -0
- /package/{src/style → old}/ignite/themes/dark.css +0 -0
- /package/{src/style → old}/ignite/themes/light.css +0 -0
- /package/{src/style → old}/ignite/utilities/shoelace.css +0 -0
- /package/{src/style → old}/ignite/utilities/utilities.css +0 -0
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<sl-spinner v-if="state.isLoading"></sl-spinner>
|
|
3
|
-
<ViForm
|
|
4
|
-
ref="addForm"
|
|
5
|
-
module="shop/address"
|
|
6
|
-
action="add"
|
|
7
|
-
:useCategories="false"
|
|
8
|
-
:layout="layout ? layout : DefaultLayout"
|
|
9
|
-
:values="modelValue"
|
|
10
|
-
:skel="
|
|
11
|
-
mode === 'shipping'
|
|
12
|
-
? cartStore.state.activeShippingAddress
|
|
13
|
-
: cartStore.state.activeBillingAddress
|
|
14
|
-
"
|
|
15
|
-
@change="updateValues"
|
|
16
|
-
>
|
|
17
|
-
</ViForm>
|
|
18
|
-
|
|
19
|
-
<sl-bar>
|
|
20
|
-
<div slot="left">
|
|
21
|
-
<!-- BUTTON NUR PLATZHALTER FÜR TESTS -->
|
|
22
|
-
<sl-button
|
|
23
|
-
variant="success"
|
|
24
|
-
@click.stop.prevent="sendForm"
|
|
25
|
-
:loading="state.isSending"
|
|
26
|
-
>
|
|
27
|
-
<sl-icon name="floppy2" slot="prefix"></sl-icon>
|
|
28
|
-
{{
|
|
29
|
-
$t("actions.add").charAt(0).toUpperCase() + $t("actions.add").slice(1)
|
|
30
|
-
}}
|
|
31
|
-
</sl-button>
|
|
32
|
-
</div>
|
|
33
|
-
</sl-bar>
|
|
34
|
-
</template>
|
|
35
|
-
|
|
36
|
-
<script setup>
|
|
37
|
-
import { reactive, ref, computed, onMounted } from "vue";
|
|
38
|
-
import ViForm from "@viur/vue-utils/forms/ViForm.vue";
|
|
39
|
-
import DefaultLayout from "./DefaultLayout.vue";
|
|
40
|
-
import { useCartStore } from "../../../stores/cart";
|
|
41
|
-
|
|
42
|
-
const props = defineProps({
|
|
43
|
-
layout: { required: false },
|
|
44
|
-
customer: { type: Object, required: true },
|
|
45
|
-
mode: { type: String, default: "shipping" },
|
|
46
|
-
modelValue: { type: Object },
|
|
47
|
-
});
|
|
48
|
-
const emit = defineEmits(["update:modelValue", "addSuccess"]);
|
|
49
|
-
const cartStore = useCartStore();
|
|
50
|
-
const addForm = ref(null);
|
|
51
|
-
const state = reactive({
|
|
52
|
-
isLoading: computed(() => (addForm.value ? addForm.value.loading : true)),
|
|
53
|
-
isSending: false,
|
|
54
|
-
wasSuccess: false,
|
|
55
|
-
user: {},
|
|
56
|
-
skel: computed(() => {
|
|
57
|
-
if (props.mode === "shipping") return cartStore.state.activeShippingAddress;
|
|
58
|
-
else return cartStore.state.activeBillingAddress;
|
|
59
|
-
}),
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
function sendForm() {
|
|
63
|
-
if (props.mode === "shipping") {
|
|
64
|
-
cartStore.state.activeShippingAddress = addForm.value.state.skel;
|
|
65
|
-
} else {
|
|
66
|
-
cartStore.state.activeBillingAddress = addForm.value.state.skel;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
state.isSending = true;
|
|
70
|
-
addForm.value.sendData().then(async (resp) => {
|
|
71
|
-
let data = await resp.json();
|
|
72
|
-
state.isSending = false;
|
|
73
|
-
if (data["action"] === "addSuccess") {
|
|
74
|
-
emit("addSuccess", {
|
|
75
|
-
show: true,
|
|
76
|
-
msg: "Erfolg!",
|
|
77
|
-
variant: "success",
|
|
78
|
-
icon: "check2-circle",
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function setSkelValues(dict = {}) {
|
|
85
|
-
let structure = cartStore.state.structure.address;
|
|
86
|
-
let skel = {};
|
|
87
|
-
|
|
88
|
-
Object.keys(structure).forEach((boneName) => {
|
|
89
|
-
if (boneName === "customer") {
|
|
90
|
-
skel[boneName] = state.user.key;
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
skel[boneName] = null;
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
Object.entries(dict).forEach(([boneName, boneValue]) => {
|
|
97
|
-
skel[boneName] = boneValue;
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
return skel;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function updateValues() {
|
|
104
|
-
emit("update:modelValue", addForm.value.state.skel);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// onBeforeMount(() => {
|
|
108
|
-
// cartStore.getAddressStructure();
|
|
109
|
-
|
|
110
|
-
// // state.skel = setSkelValues({
|
|
111
|
-
// // address_type: "shipping",
|
|
112
|
-
// // customer: props.customer.key,
|
|
113
|
-
// // });
|
|
114
|
-
// });
|
|
115
|
-
onMounted(() => {
|
|
116
|
-
cartStore.getAddressStructure();
|
|
117
|
-
// updateValues();
|
|
118
|
-
// state.skel = setSkelValues({
|
|
119
|
-
// address_type: "shipping",
|
|
120
|
-
// customer: props.customer.key,
|
|
121
|
-
// });
|
|
122
|
-
});
|
|
123
|
-
</script>
|
|
124
|
-
|
|
125
|
-
<style scoped></style>
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="viur-shop-address-box">
|
|
3
|
-
<select-address
|
|
4
|
-
v-if="addressSelection"
|
|
5
|
-
:address-list="state.addressList"
|
|
6
|
-
v-model="state.activeAddress"
|
|
7
|
-
>
|
|
8
|
-
</select-address>
|
|
9
|
-
{{state.addressList.length}}
|
|
10
|
-
<br>
|
|
11
|
-
{{cartStore.state.billingAddressList.length}}
|
|
12
|
-
<!-- debugging -->
|
|
13
|
-
<!-- {{ mode === "billing" ? cartStore.state.activeBillingAddress : "" }} -->
|
|
14
|
-
<!-- {{ mode === "billing" ? "" : cartStore.state.activeShippingAddress }} -->
|
|
15
|
-
<!-- <pre>{{ customer }}</pre> -->
|
|
16
|
-
<div class="viur-shop-address-box-preview" v-if="state.address">
|
|
17
|
-
<span>Ausgewählte Adresse :</span>
|
|
18
|
-
<br>
|
|
19
|
-
{{ state.address?.street_name }} {{ state.address?.street_number }}<br />
|
|
20
|
-
{{ state.address?.zip_code }} {{ state.address?.city }}
|
|
21
|
-
<br />
|
|
22
|
-
{{ state.address?.country }}
|
|
23
|
-
<br />
|
|
24
|
-
</div>
|
|
25
|
-
</div>
|
|
26
|
-
</template>
|
|
27
|
-
|
|
28
|
-
<script setup>
|
|
29
|
-
import {
|
|
30
|
-
reactive,
|
|
31
|
-
computed,
|
|
32
|
-
onBeforeMount,
|
|
33
|
-
watch,
|
|
34
|
-
onUpdated,
|
|
35
|
-
onUnmounted,
|
|
36
|
-
} from "vue";
|
|
37
|
-
import { useCartStore } from "../../../stores/cart";
|
|
38
|
-
import SelectAddress from "./SelectAddress.vue";
|
|
39
|
-
|
|
40
|
-
const props = defineProps({
|
|
41
|
-
mode: { type: String, default: "billing" },
|
|
42
|
-
addressSelection: { type: Boolean, default: false },
|
|
43
|
-
modelValue: { type: Object },
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const emit = defineEmits(["update:modelValue"]);
|
|
47
|
-
|
|
48
|
-
const cartStore = useCartStore();
|
|
49
|
-
|
|
50
|
-
const state = reactive({
|
|
51
|
-
addressList: computed(() =>
|
|
52
|
-
props.mode === "billing"
|
|
53
|
-
? cartStore.state.billingAddressList
|
|
54
|
-
: cartStore.state.shippingAddressList,
|
|
55
|
-
),
|
|
56
|
-
activeAddress: "",
|
|
57
|
-
address: computed(() => {
|
|
58
|
-
if (!state.activeAddress) return {};
|
|
59
|
-
|
|
60
|
-
return state.addressList.filter(
|
|
61
|
-
(address) => address.key === state.activeAddress,
|
|
62
|
-
)[0];
|
|
63
|
-
}),
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
function getDefaultAddress() {
|
|
67
|
-
if (props.mode === "billing") {
|
|
68
|
-
state.activeAddress = cartStore.state.activeBillingAddress.key
|
|
69
|
-
? cartStore.state.activeBillingAddress.key
|
|
70
|
-
: "";
|
|
71
|
-
} else {
|
|
72
|
-
state.activeAddress = cartStore.state.activeShippingAddress.key
|
|
73
|
-
? cartStore.state.activeShippingAddress.key
|
|
74
|
-
: "";
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
watch(
|
|
79
|
-
() => state.address,
|
|
80
|
-
(newAddress) => {
|
|
81
|
-
if (props.mode === "billing") {
|
|
82
|
-
cartStore.state.activeBillingAddress = newAddress;
|
|
83
|
-
} else cartStore.state.activeShippingAddress = newAddress;
|
|
84
|
-
},
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
watch(
|
|
88
|
-
() => cartStore.state.activeBillingAddress,
|
|
89
|
-
(newValue, oldValue) => {
|
|
90
|
-
state.activeAddress = newValue.key;
|
|
91
|
-
},
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
watch(
|
|
95
|
-
() => cartStore.state.activeShippingAddress,
|
|
96
|
-
(newValue, oldValue) => {
|
|
97
|
-
state.activeAddress = newValue.key;
|
|
98
|
-
},
|
|
99
|
-
);
|
|
100
|
-
onBeforeMount(() => {
|
|
101
|
-
getDefaultAddress();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
onUnmounted(() => {
|
|
105
|
-
state.activeAddress = "";
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
onUpdated(() => {
|
|
109
|
-
getDefaultAddress();
|
|
110
|
-
});
|
|
111
|
-
</script>
|
|
112
|
-
|
|
113
|
-
<style scoped>
|
|
114
|
-
.viur-shop-address-box-preview{
|
|
115
|
-
margin: var(--sl-spacing-medium) 0;
|
|
116
|
-
}
|
|
117
|
-
</style>
|
package/src/router/index.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
import { createRouter, createWebHashHistory } from "vue-router";
|
|
3
|
-
import ViewMissing from "../views/ViewMissing.vue";
|
|
4
|
-
|
|
5
|
-
const default_routes = [
|
|
6
|
-
{
|
|
7
|
-
path: "/:pathMatch(.*)*",
|
|
8
|
-
name: "view_missing",
|
|
9
|
-
component: ViewMissing,
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
path: "/shop/category/:identifier",
|
|
13
|
-
name: "CategoryView",
|
|
14
|
-
component: () => import("../components/order/category/CategoryView.vue"),
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
path: "/shop/item/:item",
|
|
18
|
-
name: "itemView",
|
|
19
|
-
component: () => import("../components/order/item/ItemView.vue"),
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
path: "/shop/cart/view",
|
|
23
|
-
name: "CartView",
|
|
24
|
-
component: () => import("../components/cart/CartView.vue"),
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
path: "/shop/order/",
|
|
28
|
-
name: "OrderView",
|
|
29
|
-
component: () => import("../components/order/process/ExampleUsage.vue"),
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
path: "/shop/order/confirm",
|
|
33
|
-
name: "ConfirmView",
|
|
34
|
-
component: () => import("../components/ShopOrderConfirm.vue"),
|
|
35
|
-
},
|
|
36
|
-
];4
|
|
37
|
-
|
|
38
|
-
function createRouterInstance(routes, replace = false) {
|
|
39
|
-
let newRoutes = [];
|
|
40
|
-
if (replace) {
|
|
41
|
-
newRoutes = routes;
|
|
42
|
-
} else {
|
|
43
|
-
newRoutes = routes.concat(default_routes);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const router = createRouter({
|
|
47
|
-
// @ts-ignore
|
|
48
|
-
history: createWebHashHistory(import.meta.env.BASE_URL),
|
|
49
|
-
routes: newRoutes,
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// router.afterEach((to, from) => {
|
|
53
|
-
// //useUserStore().addAction();
|
|
54
|
-
// });
|
|
55
|
-
|
|
56
|
-
// router.beforeEach((to, from, next) => {
|
|
57
|
-
// const contextStore = useContextStore();
|
|
58
|
-
// let localContext = {};
|
|
59
|
-
// let handlerId = to.query["_"]?.toString();
|
|
60
|
-
// if (!handlerId) next();
|
|
61
|
-
// if (Object.keys(contextStore.state.localContext).includes(handlerId)) {
|
|
62
|
-
// localContext = contextStore.state.localContext[handlerId];
|
|
63
|
-
// }
|
|
64
|
-
// let newQuery = {
|
|
65
|
-
// ...contextStore.state.globalContext,
|
|
66
|
-
// ...localContext,
|
|
67
|
-
// ...to.query,
|
|
68
|
-
// };
|
|
69
|
-
// if (
|
|
70
|
-
// Object.keys(to.query).every(
|
|
71
|
-
// (key) =>
|
|
72
|
-
// to.query[key] === newQuery[key] &&
|
|
73
|
-
// to.query.hasOwnProperty(key) &&
|
|
74
|
-
// newQuery.hasOwnProperty(key),
|
|
75
|
-
// ) &&
|
|
76
|
-
// Object.keys(newQuery).every(
|
|
77
|
-
// (key) =>
|
|
78
|
-
// to.query[key] === newQuery[key] &&
|
|
79
|
-
// to.query.hasOwnProperty(key) &&
|
|
80
|
-
// newQuery.hasOwnProperty(key),
|
|
81
|
-
// )
|
|
82
|
-
// ) {
|
|
83
|
-
// //disabled because of to much context copy and updates
|
|
84
|
-
// // Writes query to context
|
|
85
|
-
// /*
|
|
86
|
-
// for (const [k, v] of Object.entries(to.query)) {
|
|
87
|
-
// if (k.startsWith("_")) continue
|
|
88
|
-
// if (Object.keys(contextStore.state.localContext).includes(handlerId)) {
|
|
89
|
-
// contextStore.state.localContext[handlerId][k] = v
|
|
90
|
-
// } else {
|
|
91
|
-
// contextStore.state.localContext[handlerId] = { [k]: v }
|
|
92
|
-
// }
|
|
93
|
-
// }*/
|
|
94
|
-
// next(); // no change
|
|
95
|
-
// } else {
|
|
96
|
-
// to.query = newQuery;
|
|
97
|
-
// next(to);
|
|
98
|
-
// }
|
|
99
|
-
// });
|
|
100
|
-
return router;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export default createRouterInstance;
|
package/src/stores/cart.js
DELETED
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
import { reactive, computed, watch } from "vue";
|
|
2
|
-
import { defineStore } from "pinia";
|
|
3
|
-
import { ViURShopClient } from "@viur/viur-shop-client";
|
|
4
|
-
|
|
5
|
-
export const useCartStore = defineStore("cartstore", () => {
|
|
6
|
-
const shopClient = new ViURShopClient({
|
|
7
|
-
host_url:
|
|
8
|
-
window.location.origin === "http://localhost:8081"
|
|
9
|
-
? "http://localhost:8080"
|
|
10
|
-
: window.location.origin,
|
|
11
|
-
});
|
|
12
|
-
let isFetching = false;
|
|
13
|
-
const waitForFetching = [];
|
|
14
|
-
const waitForFetchingResolver = [];
|
|
15
|
-
const state = reactive({
|
|
16
|
-
basketRootNode: {},
|
|
17
|
-
basket: [],
|
|
18
|
-
wishlistRootNodes: [],
|
|
19
|
-
childrenByNode: {},
|
|
20
|
-
structure: { address: {}, cart: {} },
|
|
21
|
-
paymentProviders: {},
|
|
22
|
-
billingAddressList: [],
|
|
23
|
-
shippingAddressList: [],
|
|
24
|
-
cloneBilling: true,
|
|
25
|
-
activeBillingAddress: {},
|
|
26
|
-
activeShippingAddress: {},
|
|
27
|
-
selectedPaymentProvider: {},
|
|
28
|
-
selectedPaymentProviderName: "",
|
|
29
|
-
customer: {},
|
|
30
|
-
isLoggedIn: false,
|
|
31
|
-
placeholder: "",
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
async function init(placeholder = "") {
|
|
35
|
-
if (!isFetching) {
|
|
36
|
-
isFetching = true;
|
|
37
|
-
await getRootNodes();
|
|
38
|
-
await getCustomer();
|
|
39
|
-
await getAddress();
|
|
40
|
-
await getBasket();
|
|
41
|
-
|
|
42
|
-
isFetching = false;
|
|
43
|
-
for (const waiter of waitForFetchingResolver) {
|
|
44
|
-
waiter();
|
|
45
|
-
}
|
|
46
|
-
waitForFetchingResolver.splice(0, waitForFetchingResolver.length);
|
|
47
|
-
waitForFetching.splice(0, waitForFetchingResolver.length);
|
|
48
|
-
} else {
|
|
49
|
-
const p = new Promise((resolve, reject) => {
|
|
50
|
-
waitForFetchingResolver.push(resolve);
|
|
51
|
-
});
|
|
52
|
-
waitForFetching.push(p);
|
|
53
|
-
return p;
|
|
54
|
-
}
|
|
55
|
-
state.placeholder = placeholder;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async function getCustomer() {
|
|
59
|
-
try {
|
|
60
|
-
const resp = await shopClient.user_view();
|
|
61
|
-
state.customer = resp;
|
|
62
|
-
state.isLoggedIn = true;
|
|
63
|
-
} catch (e) {
|
|
64
|
-
state.isLoggedIn = false;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
console.log("passiert", state.customer);
|
|
68
|
-
}
|
|
69
|
-
async function getBasket() {
|
|
70
|
-
state.basket = await shopClient.basket_list();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async function getChildren(parentKey) {
|
|
74
|
-
return await shopClient.cart_list({ cart_key: parentKey });
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async function getRootNodes() {
|
|
78
|
-
let resp = await shopClient.cart_list();
|
|
79
|
-
|
|
80
|
-
resp.forEach(async (rootNode) => {
|
|
81
|
-
if (rootNode.is_root_node) {
|
|
82
|
-
if (rootNode.cart_type === "basket") {
|
|
83
|
-
state.basketRootNode = rootNode;
|
|
84
|
-
const rootChildren = await getChildren(rootNode.key);
|
|
85
|
-
state.childrenByNode[rootNode.key] = rootChildren;
|
|
86
|
-
} else {
|
|
87
|
-
state.whishlistRootNodes.push(rootNode);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
async function addToCart(articleKey, cartKey) {
|
|
94
|
-
let resp = await shopClient.article_add({
|
|
95
|
-
article_key: articleKey,
|
|
96
|
-
parent_cart_key: cartKey,
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// await updateCart(cartKey);
|
|
100
|
-
console.log("addToCart", resp); //TODO: Errorhandling as soon as shop module works again
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async function getArticleView(articleKey, cartKey) {
|
|
104
|
-
let article = await shopClient.article_view({
|
|
105
|
-
article_key: articleKey,
|
|
106
|
-
parent_cart_key: cartKey,
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
console.log("getArticleView", article); // ? Talk about necessarity
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
async function removeItem(articleKey, cartKey) {
|
|
113
|
-
let resp = await shopClient.article_remove({
|
|
114
|
-
article_key: articleKey,
|
|
115
|
-
parent_cart_key: cartKey,
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
console.log("remove Resp", resp); //TODO: Errorhandling as soon as shop module works again
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
async function updateItem(articleKey, cartKey, quantity) {
|
|
122
|
-
const resp = await shopClient.article_update({
|
|
123
|
-
article_key: articleKey,
|
|
124
|
-
parent_cart_key: cartKey,
|
|
125
|
-
quantity: quantity,
|
|
126
|
-
quantity_mode: "replace",
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
console.log("update Resp", resp); //TODO: Errorhandling as soon as shop module works again
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// async function updateCart(cartKey) {
|
|
133
|
-
// await getChildren(cartKey);
|
|
134
|
-
// }
|
|
135
|
-
|
|
136
|
-
async function getAddressStructure() {
|
|
137
|
-
const structure = await shopClient.address_structure();
|
|
138
|
-
state.structure.address = struct2dict(structure.addSkel);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function getDefaultAddress() {
|
|
142
|
-
if (!!state.billingAddressList) {
|
|
143
|
-
state.billingAddressList.forEach((address) => {
|
|
144
|
-
if (address.is_default) {
|
|
145
|
-
state.activeBillingAddress = address;
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
} else {
|
|
149
|
-
state.activeBillingAddress = setAddressValues("billing");
|
|
150
|
-
}
|
|
151
|
-
if (!!state.shippingAddressList) {
|
|
152
|
-
state.shippingAddressList.forEach((address) => {
|
|
153
|
-
if (address.is_default && !state.cloneBilling) {
|
|
154
|
-
state.activeShippingAddress = address;
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
} else {
|
|
158
|
-
if (state.cloneBilling) {
|
|
159
|
-
state.activeShippingAddress = { ...state.activeBillingAddress };
|
|
160
|
-
} else {
|
|
161
|
-
state.activeShippingAddress = setAddressValues("shipping");
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function setAddressValues(mode) {
|
|
167
|
-
let structure = state.structure.address;
|
|
168
|
-
let skel = {};
|
|
169
|
-
|
|
170
|
-
Object.entries(structure).forEach(([boneName, boneValue]) => {
|
|
171
|
-
if (boneName === "customer") {
|
|
172
|
-
skel[boneName] = state.customer.key;
|
|
173
|
-
} else if (boneName === "address_type") {
|
|
174
|
-
skel[boneName] = mode;
|
|
175
|
-
} else {
|
|
176
|
-
skel[boneName] = boneValue.emptyvalue;
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
return skel;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
async function getAddress() {
|
|
184
|
-
if (!state.isLoggedIn) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
try {
|
|
188
|
-
const addressList = await shopClient.address_list();
|
|
189
|
-
} catch (e) {
|
|
190
|
-
console.log("error", e);
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const addressList = await shopClient.address_list();
|
|
195
|
-
state.billingAddressList = [];
|
|
196
|
-
state.shippingAddressList = [];
|
|
197
|
-
|
|
198
|
-
for (const address of addressList) {
|
|
199
|
-
if (address.address_type === "billing") {
|
|
200
|
-
console.log("add to bill address ?", address);
|
|
201
|
-
state.billingAddressList.push(address);
|
|
202
|
-
}
|
|
203
|
-
if (address.address_type === "shipping") {
|
|
204
|
-
state.shippingAddressList.push(address);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
getDefaultAddress();
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
async function addDiscount(code) {
|
|
212
|
-
await shopClient.discount_add({ code });
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
async function addNode(
|
|
216
|
-
parentCart,
|
|
217
|
-
cartType = "whishlist",
|
|
218
|
-
cartName = undefined,
|
|
219
|
-
comment = undefined,
|
|
220
|
-
shipping_key = undefined,
|
|
221
|
-
shipping_address_key = undefined,
|
|
222
|
-
discount_key = undefined,
|
|
223
|
-
) {
|
|
224
|
-
return await shopClient.cart_add({
|
|
225
|
-
parent_cart_key: parentCart,
|
|
226
|
-
// cart_type: cartType, // "basket" for main cart, "whishlist" for everything else
|
|
227
|
-
// name: cartName,
|
|
228
|
-
// customer_comment: comment,
|
|
229
|
-
// shipping_address_key: shipping_address_key,
|
|
230
|
-
// shipping_key: shipping_key,
|
|
231
|
-
// discount_key: discount_key,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
async function getShippingData() {
|
|
236
|
-
return await shopClient.shipping_list({
|
|
237
|
-
cart_key: state.basketRootNode.key,
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
async function setShiping() {
|
|
241
|
-
return await shopClient.shipping_set();
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
async function getPaymentProviders() {
|
|
245
|
-
const paymentProvieders = await shopClient.payment_providers_list();
|
|
246
|
-
state.paymentProviders = paymentProvieders;
|
|
247
|
-
//select first paymentprovider as default
|
|
248
|
-
state.selectedPaymentProvider =
|
|
249
|
-
paymentProvieders[Object.keys(paymentProvieders)[0]];
|
|
250
|
-
state.selectedPaymentProviderName = Object.keys(paymentProvieders)[0];
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
function struct2dict(structure) {
|
|
254
|
-
if (!Array.isArray(structure)) {
|
|
255
|
-
return structure;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
let result = {};
|
|
259
|
-
structure.forEach((bone) => (result[bone[0]] = bone[1]));
|
|
260
|
-
|
|
261
|
-
return result;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
async function orderAdd() {
|
|
265
|
-
const order = await shopClient.order_add({
|
|
266
|
-
cart_key: state.basketRootNode.key,
|
|
267
|
-
payment_provider: state.selectedPaymentProviderName,
|
|
268
|
-
billing_address_key: state.activeBillingAddress["key"],
|
|
269
|
-
customer_key: state.customer["key"],
|
|
270
|
-
});
|
|
271
|
-
return order;
|
|
272
|
-
}
|
|
273
|
-
async function setShipping() {
|
|
274
|
-
const shipping_skel = shopClient;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
watch(
|
|
278
|
-
() => state.activeBillingAddress,
|
|
279
|
-
(newValue, oldValue) => {
|
|
280
|
-
if (oldValue) {
|
|
281
|
-
const isAddress = (address) => address.key === newValue.key;
|
|
282
|
-
|
|
283
|
-
let index = state.billingAddressList.findIndex(isAddress);
|
|
284
|
-
|
|
285
|
-
state.billingAddressList[index] = newValue;
|
|
286
|
-
}
|
|
287
|
-
if (state.cloneBilling) {
|
|
288
|
-
state.activeShippingAddress = newValue;
|
|
289
|
-
}
|
|
290
|
-
},
|
|
291
|
-
);
|
|
292
|
-
|
|
293
|
-
watch(
|
|
294
|
-
() => state.activeShippingAddress,
|
|
295
|
-
(newValue, oldValue) => {
|
|
296
|
-
if (oldValue) {
|
|
297
|
-
const isAddress = (address) => address.key === newValue.key;
|
|
298
|
-
|
|
299
|
-
let index = state.shippingAddressList.findIndex(isAddress);
|
|
300
|
-
|
|
301
|
-
state.shippingAddressList[index] = newValue;
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
);
|
|
305
|
-
|
|
306
|
-
watch(
|
|
307
|
-
() => state.cloneBilling,
|
|
308
|
-
(newValue, oldValue) => {
|
|
309
|
-
if (newValue) {
|
|
310
|
-
let temp = { ...state.activeBillingAddress };
|
|
311
|
-
temp.address_type = "shipping";
|
|
312
|
-
state.activeShippingAddress = { ...temp };
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
|
-
);
|
|
316
|
-
|
|
317
|
-
return {
|
|
318
|
-
state,
|
|
319
|
-
addToCart,
|
|
320
|
-
getArticleView,
|
|
321
|
-
removeItem,
|
|
322
|
-
updateItem,
|
|
323
|
-
init,
|
|
324
|
-
getAddressStructure,
|
|
325
|
-
getChildren,
|
|
326
|
-
addDiscount,
|
|
327
|
-
getPaymentProviders,
|
|
328
|
-
getAddress,
|
|
329
|
-
addNode,
|
|
330
|
-
getShippingData,
|
|
331
|
-
getDefaultAddress,
|
|
332
|
-
orderAdd,
|
|
333
|
-
getBasket,
|
|
334
|
-
setShiping,
|
|
335
|
-
};
|
|
336
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
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>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|