@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.
Files changed (135) hide show
  1. package/old/client/HttpClient.js +111 -0
  2. package/old/client/ViURShopClient.js +472 -0
  3. package/old/client/index.js +23 -0
  4. package/old/client/types.js +10 -0
  5. package/old/components/ExampleUsage.vue +95 -0
  6. package/old/components/ShopCart.vue +91 -0
  7. package/old/components/ShopOrderConfirm.vue +311 -0
  8. package/{src → old}/components/ShopOrderStepper.vue +111 -23
  9. package/old/components/ShopPaymentProvider.vue +113 -0
  10. package/old/components/ShopShippingMethod.vue +52 -0
  11. package/{src/components/ui → old/components}/ShopSummary.vue +28 -35
  12. package/{src → old}/components/ShopUserData.vue +51 -65
  13. package/{src → old}/components/cart/CartLeafModel.vue +24 -16
  14. package/{src → old}/components/cart/CartNode.vue +1 -0
  15. package/{src → old}/components/cart/CartTree.vue +13 -0
  16. package/old/components/cart/CartView.vue +82 -0
  17. package/{src → old}/components/cart/Discount.vue +8 -8
  18. package/old/components/generic/loadinghandler.vue +76 -0
  19. package/old/components/paymentProvider/prepayment.vue +0 -0
  20. package/old/components/paymentProvider/unzerPayment.vue +140 -0
  21. package/old/components/simple/ShopUserData.vue +161 -0
  22. package/old/components/simple/SimpleDefaultLayout.vue +116 -0
  23. package/old/components/ui/generic/CardSelector.vue +52 -0
  24. package/old/components/ui/generic/CartList.vue +69 -0
  25. package/old/components/ui/generic/ShippingInfo.vue +56 -0
  26. package/old/components/ui/generic/alerts/ShopAlert.vue +30 -0
  27. package/old/components/ui/payment/PaymentOption.vue +79 -0
  28. package/old/components/ui/payment/PaymentSelector.vue +158 -0
  29. package/old/components/ui/stepper/StepperItem.vue +90 -0
  30. package/{src → old}/components/ui/stepper/StepperTab.vue +30 -2
  31. package/old/components/ui/stepper/StepperTrigger.vue +69 -0
  32. package/old/components/ui/userdata/AddForm.vue +160 -0
  33. package/old/components/ui/userdata/AddressBox.vue +137 -0
  34. package/{src → old}/components/ui/userdata/BaseLayout.vue +15 -32
  35. package/old/stores/address.js +122 -0
  36. package/old/stores/cart.js +266 -0
  37. package/old/stores/message.js +21 -0
  38. package/old/stores/order.js +202 -0
  39. package/old/stores/payment.js +79 -0
  40. package/old/stores/shipping.js +78 -0
  41. package/package.json +3 -5
  42. package/src/Shop.vue +212 -0
  43. package/src/ShopOrderStepper.vue +89 -0
  44. package/src/ShopSummary.vue +170 -0
  45. package/src/Steps/ShopCart.vue +60 -0
  46. package/src/Steps/ShopOrderComplete.vue +24 -0
  47. package/src/Steps/ShopOrderConfirm.vue +295 -0
  48. package/src/Steps/ShopPaymentProvider.vue +53 -0
  49. package/src/Steps/ShopShippingMethod.vue +53 -0
  50. package/src/Steps/ShopUserDataGuest.vue +78 -0
  51. package/src/Steps/index.js +15 -0
  52. package/src/components/AddressForm.vue +84 -0
  53. package/src/components/AddressFormLayout.vue +107 -0
  54. package/src/components/CardSelector.vue +68 -0
  55. package/src/components/CartItem.vue +325 -0
  56. package/src/components/CartItemSmall.vue +257 -0
  57. package/src/components/LoadingHandler.vue +76 -0
  58. package/src/components/PaymentOption.vue +78 -0
  59. package/src/components/PaymentProviderUnzer.vue +201 -0
  60. package/src/components/PaymentSelector.vue +55 -0
  61. package/src/components/ShopAlert.vue +30 -0
  62. package/src/components/StepperTab.vue +132 -0
  63. package/src/components/dialogButton.vue +49 -0
  64. package/src/composables/address.js +95 -0
  65. package/src/composables/cart.js +132 -0
  66. package/src/composables/order.js +80 -0
  67. package/src/composables/payment.js +75 -0
  68. package/src/composables/shipping.js +32 -0
  69. package/src/main.js +32 -38
  70. package/src/shop.js +251 -0
  71. package/src/translations/de.js +15 -0
  72. package/src/translations/en.js +5 -0
  73. package/src/utils.js +49 -0
  74. package/vite.config.js +0 -2
  75. package/src/components/ShopCart.vue +0 -512
  76. package/src/components/ShopOrderConfirm.vue +0 -291
  77. package/src/components/cart/CartView.vue +0 -723
  78. package/src/components/order/OrderSidebar.vue +0 -102
  79. package/src/components/order/category/CategoryList.vue +0 -83
  80. package/src/components/order/category/CategoryView.vue +0 -143
  81. package/src/components/order/information/adress/ShippingAdress.vue +0 -143
  82. package/src/components/order/item/ItemCard.vue +0 -168
  83. package/src/components/order/item/ItemView.vue +0 -232
  84. package/src/components/order/process/ConfirmView.vue +0 -312
  85. package/src/components/order/process/ExampleUsage.vue +0 -113
  86. package/src/components/order/process/OrderTabHeader.vue +0 -16
  87. package/src/components/order/process/SelectPaymentProvider.vue +0 -62
  88. package/src/components/order/process/Shipping.vue +0 -46
  89. package/src/components/ui/generic/ArticleList.vue +0 -222
  90. package/src/components/ui/generic/ExamplePagination.vue +0 -236
  91. package/src/components/ui/generic/alerts/ShopAlert.vue +0 -19
  92. package/src/components/ui/generic/makeData.js +0 -39
  93. package/src/components/ui/stepper/StepperItem.vue +0 -39
  94. package/src/components/ui/stepper/StepperTrigger.vue +0 -35
  95. package/src/components/ui/userdata/AddForm.vue +0 -125
  96. package/src/components/ui/userdata/AddressBox.vue +0 -117
  97. package/src/router/index.js +0 -103
  98. package/src/stores/cart.js +0 -336
  99. package/src/views/ViewMissing.vue +0 -20
  100. /package/{src → old}/components/ShopOrderComplete.vue +0 -0
  101. /package/{src → old}/components/cart/CartLeaf.vue +0 -0
  102. /package/{src → old}/components/cart/CartTreeWrapper.vue +0 -0
  103. /package/{src/components/lib/utils.js → old/components/paymentProvider/paypalplus.vue} +0 -0
  104. /package/{src → old}/components/ui/generic/ShopPriceFormatter.vue +0 -0
  105. /package/{src → old}/components/ui/userdata/CustomBooleanBone.vue +0 -0
  106. /package/{src → old}/components/ui/userdata/CustomSelectBone.vue +0 -0
  107. /package/{src → old}/components/ui/userdata/CustomStringBone.vue +0 -0
  108. /package/{src → old}/components/ui/userdata/DefaultLayout.vue +0 -0
  109. /package/{src → old}/components/ui/userdata/SelectAddress.vue +0 -0
  110. /package/{src → old}/components/ui/userdata/multi/ActionBar.vue +0 -0
  111. /package/{src → old}/components/ui/userdata/multi/CartSelection.vue +0 -0
  112. /package/{src/style → old}/ignite/.editorconfig +0 -0
  113. /package/{src/style → old}/ignite/.github/workflows/ignite.yml +0 -0
  114. /package/{src/style → old}/ignite/.github/workflows/node.yml +0 -0
  115. /package/{src/style → old}/ignite/.postcssrc.cjs +0 -0
  116. /package/{src/style → old}/ignite/CHANGELOG.md +0 -0
  117. /package/{src/style → old}/ignite/LICENSE +0 -0
  118. /package/{src/style → old}/ignite/README.md +0 -0
  119. /package/{src/style → old}/ignite/dist/ignite.css +0 -0
  120. /package/{src/style → old}/ignite/dist/ignite.min.css +0 -0
  121. /package/{src/style → old}/ignite/foundation/basic.css +0 -0
  122. /package/{src/style → old}/ignite/foundation/color.css +0 -0
  123. /package/{src/style → old}/ignite/foundation/config.css +0 -0
  124. /package/{src/style → old}/ignite/foundation/grid.css +0 -0
  125. /package/{src/style → old}/ignite/foundation/mediaqueries.css +0 -0
  126. /package/{src/style → old}/ignite/foundation/reset.css +0 -0
  127. /package/{src/style → old}/ignite/ignite.css +0 -0
  128. /package/{src/style → old}/ignite/ignite.css.map +0 -0
  129. /package/{src/style → old}/ignite/package-lock.json +0 -0
  130. /package/{src/style → old}/ignite/package.json +0 -0
  131. /package/{src/style → old}/ignite/shoelace.css +0 -0
  132. /package/{src/style → old}/ignite/themes/dark.css +0 -0
  133. /package/{src/style → old}/ignite/themes/light.css +0 -0
  134. /package/{src/style → old}/ignite/utilities/shoelace.css +0 -0
  135. /package/{src/style → old}/ignite/utilities/utilities.css +0 -0
@@ -0,0 +1,202 @@
1
+ import { reactive } from "vue";
2
+ import { defineStore } from "pinia";
3
+ import { useCartStore } from "./cart";
4
+ import { useMessageStore } from "./message";
5
+ import { Request } from '@viur/vue-utils'
6
+ import { useUrlSearchParams } from '@vueuse/core'
7
+
8
+ export const useOrderStore = defineStore("shop-order", () => {
9
+ const cartStore = useCartStore();
10
+ const messageStore = useMessageStore();
11
+
12
+ const state = reactive({
13
+ currentOrderkey:null,
14
+ currentOrder: null,
15
+ shopClient: undefined,
16
+ updateParams: {},
17
+ paramsChanged: false,
18
+ checkoutState: null, // null "prepare","start", ...
19
+ checkout: null,
20
+ });
21
+
22
+ function getOrder(){
23
+ return new Promise(async (resolve, reject) => {
24
+ if (!state.currentOrderkey){
25
+ resolve()
26
+ }
27
+ try{
28
+ const response = await Request.post(state.shopClient.shop_api_url+"/order_view",{dataObj:{
29
+ "order_key": state.currentOrderkey
30
+ }})
31
+
32
+
33
+ console.log(response)
34
+ const data = await response.json()
35
+ console.log(data['skel'])
36
+ state.currentOrder = data['skel']
37
+
38
+ } catch(error){
39
+ state.currentOrder = null
40
+ }
41
+ resolve()
42
+ })
43
+ }
44
+
45
+ function add(obj) {
46
+ return new Promise((resolve, reject) => {
47
+ state.shopClient
48
+ .order_add(obj)
49
+ .then(async (resp) => {
50
+ let data = await resp;
51
+ state.currentOrder = data;
52
+ state.currentOrderkey = data["key"]
53
+ const params = useUrlSearchParams('hash')
54
+ params['order'] = state.currentOrderkey
55
+ resolve(data);
56
+ })
57
+ .catch((error) => {
58
+ messageStore.state.errors.push({
59
+ msg: error,
60
+ variant: "danger",
61
+ iconName: "x-lg",
62
+ id: new Date().getTime(),
63
+ duration: "Infinity",
64
+ closeable: false,
65
+ });
66
+ reject(error);
67
+ });
68
+ });
69
+ }
70
+
71
+ function update() {
72
+ Object.assign(state.updateParams, {
73
+ order_key: state.currentOrder.key,
74
+ });
75
+
76
+ return new Promise((resolve, reject) => {
77
+ state.shopClient
78
+ .order_update(state.updateParams)
79
+ .then(async (resp) => {
80
+ let data = await resp;
81
+ state.currentOrder = data;
82
+ state.currentOrderkey = data["key"]
83
+ state.paramsChanged = false;
84
+ resolve(data);
85
+ })
86
+ .catch((error) => {
87
+ messageStore.state.errors.push({
88
+ msg: error,
89
+ variant: "danger",
90
+ iconName: "x-lg",
91
+ id: new Date().getTime(),
92
+ duration: "Infinity",
93
+ closeable: false,
94
+ });
95
+ reject(error);
96
+ });
97
+ });
98
+ }
99
+
100
+ function getExistingOrder() {
101
+ // needs clarification
102
+ }
103
+
104
+ function updateParams(obj = {}) {
105
+ if (!Object.keys(obj).length) {
106
+ return;
107
+ }
108
+
109
+ for (let [k, v] of Object.entries(obj)) {
110
+ if (state.updateParams?.[k] !== v) {
111
+ Object.assign(state.updateParams, obj);
112
+ state.paramsChanged = true;
113
+ return;
114
+ }
115
+ }
116
+ }
117
+
118
+ function handler() {
119
+ /* Accepted Parameters
120
+ (*** required fields; only 1 of the required fields need to be set)
121
+ obj = {
122
+ cart_key: "key",
123
+ payment_provider: "payment_provider key",
124
+ billing_address_key: "billing_address_key",
125
+ email: "email", ***
126
+ customer_key: "customer_key", ***
127
+ state_ordered: "state",
128
+ state_paid: "state",
129
+ state_rts: "state",
130
+ }; */
131
+
132
+ if (
133
+ !(
134
+ state.updateParams &&
135
+ (state.updateParams.email || state.updateParams.customer_key)
136
+ )
137
+ ) {
138
+ state.updateParams.customer_key = cartStore.state.customer.key;
139
+ }
140
+
141
+ if (!state.currentOrder) {
142
+ // TODO: getExistingOrder().then(state.currentOrder = value).error(add(params)...)
143
+
144
+ if (!state.updateParams.cart_key) {
145
+ state.updateParams.cart_key = cartStore.state.basket.key;
146
+ }
147
+
148
+ add(state.updateParams);
149
+ } else {
150
+ if (state.paramsChanged) {
151
+ update();
152
+ }
153
+ }
154
+ }
155
+
156
+ function add_or_update(){
157
+ if (
158
+ !(
159
+ state.updateParams &&
160
+ (state.updateParams.email || state.updateParams.customer_key)
161
+ )
162
+ ) {
163
+ state.updateParams.customer_key = cartStore.state.customer.key;
164
+ }
165
+
166
+ if (!state.currentOrder) {
167
+ // TODO: getExistingOrder().then(state.currentOrder = value).error(add(params)...)
168
+
169
+ if (!state.updateParams.cart_key) {
170
+ state.updateParams.cart_key = cartStore.state.basket.key;
171
+ }
172
+
173
+ add(state.updateParams);
174
+ } else {
175
+ if (state.paramsChanged) {
176
+ update();
177
+ }
178
+ }
179
+ }
180
+
181
+
182
+ async function startCheckout() {
183
+ try {
184
+ state.checkout = await state.shopClient.order_checkout_start({
185
+ order_key: state.currentOrder.key,
186
+ });
187
+ cartStore.state.freeze = true;
188
+ } catch (error) {
189
+ console.log(state.checkout);
190
+ console.dir(error);
191
+ }
192
+ }
193
+
194
+ return {
195
+ state,
196
+ handler,
197
+ startCheckout,
198
+ updateParams,
199
+ getOrder,
200
+ add_or_update
201
+ };
202
+ });
@@ -0,0 +1,79 @@
1
+ import { reactive, computed, watch } from "vue";
2
+ import { defineStore } from "pinia";
3
+ import { Request } from "@viur/vue-utils";
4
+ import { useCartStore } from "./cart";
5
+ import { useOrderStore } from './order'
6
+
7
+ export const usePaymentStore = defineStore("payment-shipping", () => {
8
+ const cartStore = useCartStore()
9
+ const orderStore = useOrderStore()
10
+
11
+ const state = reactive({
12
+ paymentProviders: [], //payment options
13
+ paymentInstances:[],
14
+ paymentSelection:null,
15
+ isLoading:false,
16
+ isUpdating:false,
17
+ hasError:false,
18
+ errorMessage:"",
19
+ init:true, //fetch onMount and store is ready
20
+ paymentHandler:{}
21
+ })
22
+
23
+ async function getPaymentProviders() {
24
+ state.paymentSelection = null
25
+ state.isLoading = true
26
+ state.isUpdating = false
27
+ state.hasError = false
28
+ try{
29
+ let providersObject = await cartStore.state.shopClient.payment_providers_list()
30
+ state.paymentProviders = Object.entries(providersObject) // cardselector needs a list
31
+ state.isLoading = false
32
+ if(state.paymentProviders.length===0){
33
+ state.hasError = true
34
+ state.errorMessage = "Keine gültige Bezahlart gefunden."
35
+ }
36
+ } catch (error) {
37
+ console.log(error)
38
+ state.isLoading = false
39
+ state.hasError = true
40
+ state.errorMessage = "Keine gültige Bezahlart gefunden."
41
+ }
42
+ }
43
+
44
+ async function initPayment(){
45
+ if (!state.init) return false
46
+ await cartStore.init() // ensure store config starts loading
47
+ if (!orderStore.state.currentOrder || Object.keys(orderStore.state.currentOrder).length===0){
48
+ /*
49
+ state.hasError = true
50
+ state.errorMessage = "Keine gültige Bestellung gefunden"
51
+ return false */
52
+ } // we need a valid order
53
+
54
+
55
+ if (cartStore.state.isReady){
56
+ await getPaymentProviders() // request Payment data based on current cart
57
+ }
58
+ return true
59
+ }
60
+
61
+ function updateOrder(){
62
+ console.log("updateOrder payment", orderStore.state.currentOrder)
63
+ orderStore.updateParams({
64
+ payment_provider: state.paymentSelection[0]
65
+ })
66
+ return true
67
+ }
68
+
69
+ watch(()=>cartStore.state.isReady, async(newVal, oldVal)=>{
70
+ await initPayment() // auto fetch if shop is ready
71
+ })
72
+
73
+ return {
74
+ state,
75
+ getPaymentProviders,
76
+ initPayment,
77
+ updateOrder
78
+ }
79
+ })
@@ -0,0 +1,78 @@
1
+ import { reactive, computed, watch } from "vue";
2
+ import { defineStore } from "pinia";
3
+ import { Request } from "@viur/vue-utils";
4
+ import {useCartStore} from "./cart";
5
+ import { useOrderStore } from './order';
6
+
7
+ export const useShippingStore = defineStore("shop-shipping", () => {
8
+ const cartStore = useCartStore()
9
+ const orderStore = useOrderStore()
10
+
11
+ const state = reactive({
12
+ shippingData: [], //shippingoptions
13
+ selectedShippingMethod:null,
14
+ isLoading:false,
15
+ isUpdating:false,
16
+ hasError:false,
17
+ errorMessage:"",
18
+ init:true //fetch onMount or store is ready
19
+ })
20
+
21
+ async function getShippingData() {
22
+ state.shippingSelection = null
23
+ state.isLoading = true
24
+ state.isUpdating = false
25
+ state.hasError = false
26
+ try{
27
+ state.shippingData = await cartStore.state.shopClient.shipping_list({
28
+ cart_key: cartStore.state.currentbasketKey,
29
+ })
30
+ state.isLoading = false
31
+ if(state.shippingData.length===0){
32
+ state.hasError = true
33
+ state.errorMessage = "Keine gültige Versandart gefunden."
34
+ }
35
+ } catch (error) {
36
+ state.isLoading = false
37
+ state.hasError = true
38
+ state.errorMessage = "Keine gültige Versandart gefunden."
39
+ }
40
+ }
41
+
42
+ async function updateCart(){
43
+ if (!state.selectedShippingMethod) return false
44
+ let result = await cartStore.state.shopClient.cart_update({
45
+ cart_key: orderStore.state.currentOrder.cart.dest.key,
46
+ shipping_key: state.selectedShippingMethod['dest']['key']
47
+ })
48
+ if (!result?.['shipping']){
49
+ return false
50
+ }
51
+ return true
52
+ }
53
+
54
+
55
+ async function initShipping(){
56
+ if (! state.init) return false
57
+
58
+ await cartStore.init() // ensure store config starts loading
59
+ if (cartStore.state.isReady){
60
+ await getShippingData() // request shipping data based on current cart
61
+ }
62
+
63
+ return true
64
+ }
65
+
66
+ watch(()=>cartStore.state.isReady, async(newVal, oldVal)=>{
67
+ if (state.init){
68
+ await getShippingData() // auto fetch if shop is ready
69
+ }
70
+ })
71
+
72
+ return {
73
+ state,
74
+ getShippingData,
75
+ initShipping,
76
+ updateCart
77
+ }
78
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viur/shop-components",
3
- "version": "0.0.1-dev.60",
3
+ "version": "0.0.1-dev.61",
4
4
  "description": "Frontend Vue components for the shop module of ViUR",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,10 +25,8 @@
25
25
  "dependencies": {
26
26
  "@tanstack/vue-table": "^8.20.5",
27
27
  "@viur/ignite": "^5.1.2",
28
- "@viur/shoelace": "^1.0.8-v2.17.1",
29
- "@viur/viur-shop-client": "^0.3.0",
30
- "@viur/vue-components": "^1.7.12",
31
- "@viur/vue-utils": "^1.7.18",
28
+ "@viur/shoelace": "^1.0.8-v2.19.0",
29
+ "@viur/vue-utils": "^1.7.22",
32
30
  "@vueuse/core": "^11.1.0",
33
31
  "pinia": "^2.2.4",
34
32
  "primevue": "^4.1.1",
package/src/Shop.vue ADDED
@@ -0,0 +1,212 @@
1
+ <template>
2
+ <div class="bind viur-shop-wrap">
3
+ <div class="viur-shop-stepper-wrap"
4
+ :class="{ 'full-width': (!summary || summary==='bottom' || shopStore.state.currentTab==='complete') }"
5
+ >
6
+ <shop-order-stepper v-if="shopStore.state.cartReady && shopStore.state.orderReady">
7
+ </shop-order-stepper>
8
+ </div>
9
+
10
+ <div class="viur-shop-sidebar-wrap" v-if="false" :class="{ bottom: (summary==='bottom') }">
11
+ <shop-summary></shop-summary>
12
+ </div>
13
+ </div>
14
+
15
+ <sl-details summary="Debug" open>
16
+ language: {{shopStore.state.language}} <br>
17
+ order: {{ shopStore.state.orderKey }}<br>
18
+ cart: {{ shopStore.state.cartRoot?.['key'] }}<br><br>
19
+
20
+ shippingaddress: {{shopStore.state.cartRoot?.['shipping_address']}}<br>
21
+ billingaddress: {{shopStore.state.order?.['billing_address']}}<br><br>
22
+
23
+ shipping: {{shopStore.state.cartRoot?.['shipping']}}<br><br>
24
+ Payment: {{shopStore.state.order?.['payment_provider']}}<br><br>
25
+
26
+ Order Status<br>
27
+ ------<br>
28
+ canCheckout: {{ shopStore.state.canCheckout }}<br>
29
+ canOrder: {{ shopStore.state.canOrder }}<br>
30
+ CheckoutStarted: {{ shopStore.state.order?.['is_checkout_in_progress'] }}<br><br>
31
+
32
+ ordered: {{ shopStore.state.order?.['is_ordered'] }}<br>
33
+ readytoship: {{ shopStore.state.order?.['is_rts'] }}<br>
34
+ paid: {{ shopStore.state.order?.['is_paid'] }}<br><br>
35
+
36
+ OrderObject: {{shopStore.state.order}}
37
+
38
+
39
+ </sl-details>
40
+
41
+ <div id="dialogs"></div>
42
+ </template>
43
+
44
+
45
+ <script setup>
46
+ import { onBeforeMount } from 'vue';
47
+ import ShopOrderStepper from './ShopOrderStepper.vue'
48
+ import ShopSummary from "./ShopSummary.vue"
49
+ import {useViurShopStore} from './shop'
50
+ import { useUrlSearchParams } from '@vueuse/core'
51
+ import { useOrder } from './composables/order';
52
+ import { useCart } from './composables/cart';
53
+
54
+
55
+ const shopStore = useViurShopStore()
56
+ const {fetchOrder} = useOrder()
57
+ const {fetchCart} = useCart()
58
+
59
+ const props = defineProps({
60
+ summary:{
61
+ default:false
62
+ }, // bottom, sidebar
63
+ initTab:{
64
+ default:'cart'
65
+ },
66
+ modulename:{
67
+ default:'shop'
68
+ },
69
+ language:{
70
+ default:"de"
71
+ }
72
+ })
73
+
74
+
75
+ onBeforeMount(()=>{
76
+ shopStore.state.language=props.language
77
+ if(props.tabs){
78
+ shopStore.state.tabs = props.tabs
79
+ }
80
+
81
+ shopStore.state.moduleName= props.modulename
82
+ fetchCart()
83
+ shopStore.fetchMetaData()
84
+ const params = useUrlSearchParams('hash')
85
+ if (Object.keys(params).includes('order')){
86
+ shopStore.state.orderKey = params['order']
87
+ fetchOrder(shopStore.state.orderKey).then(()=>{
88
+ shopStore.state.orderReady = true
89
+ // navigate to order state
90
+ if(shopStore.state.order?.['is_ordered']){
91
+ shopStore.navigateToTab('complete')
92
+ } else if (shopStore.state.order?.['is_checkout_in_progress']){
93
+ shopStore.navigateToTab('confirm')
94
+ }
95
+ })
96
+ }else{
97
+ shopStore.state.orderReady = true
98
+ }
99
+
100
+
101
+ if (Object.keys(params).includes('step')){
102
+ shopStore.navigateToTab(params['step'])
103
+ }else{
104
+ shopStore.navigateToTab('cart')
105
+ }
106
+
107
+
108
+
109
+
110
+ })
111
+
112
+
113
+
114
+ </script>
115
+
116
+ <style scoped>
117
+
118
+ * {
119
+ box-sizing: border-box;
120
+ }
121
+
122
+ .viur-shop-wrap {
123
+ --shop-sidebar-background: var(--sl-color-neutral-100);
124
+ --shop-sidebar-columns: 4;
125
+ --shop-main-columns: 8;
126
+ --shop-tab-color: var(--sl-color-neutral-400);
127
+ --shop-tab-color-active: var(--ignt-color-primary);
128
+
129
+ --shop-form-headline-size: 1.5em;
130
+ --shop-success-headline-size: var(--shop-form-headline-size);
131
+
132
+ display: grid;
133
+ grid-template-columns: repeat(12, minmax(0, 1fr));
134
+ grid-template-rows: 1fr max-content;
135
+ grid-gap: var(--ignt-spacing-2x-large);
136
+
137
+ width: 100%;
138
+ border: 0 white solid;
139
+ }
140
+
141
+ @layer foundation.shop {
142
+ .viur-shop-sidebar-wrap {
143
+ --padding: var(--sl-spacing-large);
144
+
145
+ display: flex;
146
+ flex-direction: column;
147
+ background-color: var(--shop-sidebar-background);
148
+ padding: var(--sl-spacing-medium);
149
+ overflow: hidden;
150
+ border-radius: var(--sl-border-radius-medium);
151
+ grid-column: auto / span var(--shop-sidebar-columns);
152
+ /* height has to be set or sidebar grows until infinity... */
153
+ height: min-content;
154
+ @media (min-width: 1024px) {
155
+ position: sticky;
156
+ max-height: calc(100vh - 2 * var(--padding));
157
+ top: var(--padding);
158
+ bottom: var(--padding);
159
+ }
160
+ }
161
+
162
+ .viur-shop-stepper-wrap {
163
+ display: flex;
164
+ flex-direction: column;
165
+ grid-column: auto / span var(--shop-main-columns);
166
+
167
+ @media (max-width: 1024px) {
168
+ grid-column: auto / span 12;
169
+ }
170
+
171
+ @media (max-width: 600px) {
172
+ &::part(active-tab-indicator) {
173
+ display: none;
174
+ }
175
+ }
176
+ }
177
+
178
+ .viur-shop-form-footer {
179
+ height: fit-content;
180
+
181
+ /* TODO: sticky Trigger yes no? */
182
+ /* position: sticky;
183
+ bottom: 2rem; */
184
+ }
185
+
186
+ :deep(.viur-shop-form-footer) {
187
+ display: flex;
188
+ justify-content: space-between;
189
+ margin-top: var(--sl-spacing-large);
190
+ }
191
+
192
+ .flex-end {
193
+ justify-content: flex-end;
194
+ }
195
+
196
+ .bottom {
197
+ grid-column: auto / span 12;
198
+ grid-row-start: 2;
199
+ }
200
+
201
+ .full-width {
202
+ grid-column: auto / span 12;
203
+ }
204
+
205
+ .last-row {
206
+ grid-row-start: 3;
207
+ }
208
+ }
209
+
210
+
211
+
212
+ </style>
@@ -0,0 +1,89 @@
1
+ <template>
2
+ <sl-tab-group
3
+ class="viur-shop-order-tabgroup"
4
+ noScrollControls
5
+ ref="stepper"
6
+ >
7
+ <template v-for="(tab,name) in shopStore.state.tabs">
8
+ <StepperTab
9
+ :tab="name"
10
+ >
11
+ </StepperTab>
12
+
13
+ <sl-tab-panel :name="name">
14
+ <template v-if="tab?.['loaded']">
15
+ <component :is="tab['component']">
16
+ <template v-slot="slotProps">
17
+ <sl-bar>
18
+ <div slot="right">
19
+ <sl-button
20
+ variant="primary"
21
+ :disabled="active(slotProps)"
22
+ @click="nextStep(slotProps)"
23
+ :loading="tab['validating']"
24
+ >
25
+ {{slotProps.nextName}}
26
+ </sl-button>
27
+ </div>
28
+ </sl-bar>
29
+ </template>
30
+ </component>
31
+ </template>
32
+ </sl-tab-panel>
33
+ </template>
34
+ </sl-tab-group>
35
+ </template>
36
+
37
+ <script setup>
38
+ import {reactive, shallowRef, watch, ref, onBeforeMount, onMounted} from 'vue'
39
+ import {useViurShopStore} from './shop'
40
+ import StepperTab from './components/StepperTab.vue'
41
+
42
+ const shopStore = useViurShopStore()
43
+ const stepper = ref()
44
+
45
+
46
+ // Activate Tab if currentTab changes
47
+ watch(()=>shopStore.state.currentTab, (newVal, oldVal)=>{
48
+ stepper.value.show(shopStore.state.currentTab)
49
+ shopStore.state.tabs[shopStore.state.currentTab]['loaded'] = true
50
+ })
51
+
52
+ onMounted(()=>{
53
+ // wait shoelace component is ready
54
+ stepper.value.updateComplete.then(() => {
55
+ shopStore.state.tabs[shopStore.state.currentTab]['loaded'] = true
56
+ stepper.value.show(shopStore.state.currentTab)
57
+ })
58
+ })
59
+
60
+ function nextStep(obj){
61
+ shopStore.state.tabs[shopStore.state.currentTab]['valid']=false
62
+ shopStore.state.tabs[shopStore.state.currentTab]['validating']=true
63
+ //validate step, like send forms or something like this
64
+ Promise.resolve(obj.nextfunction()).then((resp)=>{
65
+ if (resp){
66
+ shopStore.state.tabs[shopStore.state.currentTab]['valid']=true
67
+ shopStore.state.tabs[shopStore.state.currentTab]['validating']=false
68
+ shopStore.navigateToNext()
69
+ }else{
70
+ shopStore.state.tabs[shopStore.state.currentTab]['valid']=false
71
+ shopStore.state.tabs[shopStore.state.currentTab]['validating']=false
72
+ }
73
+ }).catch(error=>{
74
+ shopStore.state.tabs[shopStore.state.currentTab]['valid']=false
75
+ shopStore.state.tabs[shopStore.state.currentTab]['validating']=false
76
+ })
77
+ console.log("----")
78
+ }
79
+
80
+ function active(obj){
81
+ return !obj.activefunction()
82
+ }
83
+
84
+ </script>
85
+
86
+ <style scoped>
87
+
88
+
89
+ </style>