@viur/shop-components 0.0.1-dev.6 → 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 (131) hide show
  1. package/.editorconfig +16 -0
  2. package/.github/workflows/npm-publish.yml +42 -0
  3. package/.gitmodules +3 -0
  4. package/LICENSE +21 -0
  5. package/README.md +13 -2
  6. package/old/client/HttpClient.js +111 -0
  7. package/old/client/ViURShopClient.js +472 -0
  8. package/old/client/index.js +23 -0
  9. package/old/client/types.js +10 -0
  10. package/old/components/ExampleUsage.vue +95 -0
  11. package/old/components/ShopCart.vue +91 -0
  12. package/old/components/ShopOrderComplete.vue +73 -0
  13. package/old/components/ShopOrderConfirm.vue +311 -0
  14. package/old/components/ShopOrderStepper.vue +352 -0
  15. package/old/components/ShopPaymentProvider.vue +113 -0
  16. package/old/components/ShopShippingMethod.vue +52 -0
  17. package/old/components/ShopSummary.vue +138 -0
  18. package/old/components/ShopUserData.vue +218 -0
  19. package/old/components/cart/CartLeaf.vue +277 -0
  20. package/old/components/cart/CartLeafModel.vue +312 -0
  21. package/old/components/cart/CartNode.vue +26 -0
  22. package/old/components/cart/CartTree.vue +67 -0
  23. package/old/components/cart/CartTreeWrapper.vue +73 -0
  24. package/old/components/cart/CartView.vue +82 -0
  25. package/old/components/cart/Discount.vue +91 -0
  26. package/old/components/generic/loadinghandler.vue +76 -0
  27. package/old/components/paymentProvider/paypalplus.vue +0 -0
  28. package/old/components/paymentProvider/prepayment.vue +0 -0
  29. package/old/components/paymentProvider/unzerPayment.vue +140 -0
  30. package/old/components/simple/ShopUserData.vue +161 -0
  31. package/old/components/simple/SimpleDefaultLayout.vue +116 -0
  32. package/old/components/ui/generic/CardSelector.vue +52 -0
  33. package/old/components/ui/generic/CartList.vue +69 -0
  34. package/old/components/ui/generic/ShippingInfo.vue +56 -0
  35. package/old/components/ui/generic/ShopPriceFormatter.vue +41 -0
  36. package/old/components/ui/generic/alerts/ShopAlert.vue +30 -0
  37. package/old/components/ui/payment/PaymentOption.vue +79 -0
  38. package/old/components/ui/payment/PaymentSelector.vue +158 -0
  39. package/old/components/ui/stepper/StepperItem.vue +90 -0
  40. package/old/components/ui/stepper/StepperTab.vue +161 -0
  41. package/old/components/ui/stepper/StepperTrigger.vue +69 -0
  42. package/old/components/ui/userdata/AddForm.vue +160 -0
  43. package/old/components/ui/userdata/AddressBox.vue +137 -0
  44. package/old/components/ui/userdata/BaseLayout.vue +77 -0
  45. package/old/components/ui/userdata/CustomBooleanBone.vue +58 -0
  46. package/old/components/ui/userdata/CustomSelectBone.vue +91 -0
  47. package/old/components/ui/userdata/CustomStringBone.vue +71 -0
  48. package/old/components/ui/userdata/DefaultLayout.vue +126 -0
  49. package/old/components/ui/userdata/SelectAddress.vue +21 -0
  50. package/old/components/ui/userdata/multi/ActionBar.vue +38 -0
  51. package/old/components/ui/userdata/multi/CartSelection.vue +42 -0
  52. package/old/ignite/.editorconfig +20 -0
  53. package/old/ignite/.github/workflows/ignite.yml +64 -0
  54. package/old/ignite/.github/workflows/node.yml +30 -0
  55. package/old/ignite/.postcssrc.cjs +25 -0
  56. package/old/ignite/CHANGELOG.md +244 -0
  57. package/old/ignite/LICENSE +21 -0
  58. package/old/ignite/README.md +92 -0
  59. package/old/ignite/dist/ignite.css +2019 -0
  60. package/old/ignite/dist/ignite.min.css +4 -0
  61. package/old/ignite/foundation/basic.css +371 -0
  62. package/old/ignite/foundation/color.css +323 -0
  63. package/old/ignite/foundation/config.css +188 -0
  64. package/old/ignite/foundation/grid.css +78 -0
  65. package/old/ignite/foundation/mediaqueries.css +71 -0
  66. package/old/ignite/foundation/reset.css +261 -0
  67. package/old/ignite/ignite.css +29 -0
  68. package/old/ignite/ignite.css.map +1 -0
  69. package/old/ignite/package-lock.json +5530 -0
  70. package/old/ignite/package.json +58 -0
  71. package/old/ignite/shoelace.css +19 -0
  72. package/old/ignite/themes/dark.css +12 -0
  73. package/old/ignite/themes/light.css +11 -0
  74. package/old/ignite/utilities/shoelace.css +537 -0
  75. package/old/ignite/utilities/utilities.css +24 -0
  76. package/old/stores/address.js +122 -0
  77. package/old/stores/cart.js +266 -0
  78. package/old/stores/message.js +21 -0
  79. package/old/stores/order.js +202 -0
  80. package/old/stores/payment.js +79 -0
  81. package/old/stores/shipping.js +78 -0
  82. package/package.json +23 -23
  83. package/src/Shop.vue +212 -0
  84. package/src/ShopOrderStepper.vue +89 -0
  85. package/src/ShopSummary.vue +170 -0
  86. package/src/Steps/ShopCart.vue +60 -0
  87. package/src/Steps/ShopOrderComplete.vue +24 -0
  88. package/src/Steps/ShopOrderConfirm.vue +295 -0
  89. package/src/Steps/ShopPaymentProvider.vue +53 -0
  90. package/src/Steps/ShopShippingMethod.vue +53 -0
  91. package/src/Steps/ShopUserDataGuest.vue +78 -0
  92. package/src/Steps/index.js +15 -0
  93. package/src/components/AddressForm.vue +84 -0
  94. package/src/components/AddressFormLayout.vue +107 -0
  95. package/src/components/CardSelector.vue +68 -0
  96. package/src/components/CartItem.vue +325 -0
  97. package/src/components/CartItemSmall.vue +257 -0
  98. package/src/components/LoadingHandler.vue +76 -0
  99. package/src/components/PaymentOption.vue +78 -0
  100. package/src/components/PaymentProviderUnzer.vue +201 -0
  101. package/src/components/PaymentSelector.vue +55 -0
  102. package/src/components/ShopAlert.vue +30 -0
  103. package/src/components/StepperTab.vue +132 -0
  104. package/src/components/dialogButton.vue +49 -0
  105. package/src/composables/address.js +95 -0
  106. package/src/composables/cart.js +132 -0
  107. package/src/composables/order.js +80 -0
  108. package/src/composables/payment.js +75 -0
  109. package/src/composables/shipping.js +32 -0
  110. package/src/main.js +44 -0
  111. package/src/shop.js +251 -0
  112. package/src/translations/de.js +15 -0
  113. package/src/translations/en.js +5 -0
  114. package/src/utils.js +49 -0
  115. package/vite.config.js +51 -0
  116. package/src/components/cart/CartView.vue +0 -692
  117. package/src/components/cart/ConfirmView.vue +0 -314
  118. package/src/components/order/category/CategoryList.vue +0 -83
  119. package/src/components/order/category/CategoryView.vue +0 -143
  120. package/src/components/order/information/UserInfoMulti.vue +0 -427
  121. package/src/components/order/information/UserInformation.vue +0 -332
  122. package/src/components/order/information/adress/ShippingAdress.vue +0 -143
  123. package/src/components/order/item/ItemCard.vue +0 -168
  124. package/src/components/order/item/ItemView.vue +0 -233
  125. package/src/components/order/process/ExampleUsage.vue +0 -100
  126. package/src/components/order/process/OrderComplete.vue +0 -41
  127. package/src/components/order/process/OrderTabHeader.vue +0 -7
  128. package/src/components/order/process/OrderView.vue +0 -210
  129. package/src/router/index.js +0 -103
  130. package/src/stores/cart.js +0 -111
  131. package/src/views/ViewMissing.vue +0 -20
@@ -0,0 +1,352 @@
1
+ <template>
2
+ <template v-for="msg in messageStore.state.errors">
3
+ <shop-alert
4
+ v-if="!messageStore.state.blacklist.includes(msg.id)"
5
+ :msg="msg.msg"
6
+ :variant="msg.variant"
7
+ :iconName="msg.iconName"
8
+ :duration="msg?.duration ? msg.duration : 3000"
9
+ :closeable="msg.closeable"
10
+ :key="msg.id"
11
+ @sl-hide="messageStore.state.blacklist.push(msg.id)"
12
+ >
13
+ </shop-alert>
14
+ </template>
15
+
16
+ <sl-dialog
17
+ no-header
18
+ ref="freezeCart"
19
+ @sl-hide="
20
+ cartStore.state.freeze ? () => {} : tabGroup.show(state.tabNames[0])
21
+ "
22
+ >
23
+ <p>Wollen sie fortfahren?</p>
24
+ <i>*Der Warenkorb kann nicht mehr verändert werden bei Bestätigung</i>
25
+ <sl-bar>
26
+ <sl-button
27
+ slot="left"
28
+ variant="danger"
29
+ @click="freezeCart.hide()"
30
+ size="medium"
31
+ >
32
+ Abbrechen
33
+ </sl-button>
34
+ <sl-button
35
+ slot="right"
36
+ variant="success"
37
+ @click="onFreezeCart"
38
+ size="medium"
39
+ >
40
+ Bestätigen
41
+ </sl-button>
42
+ </sl-bar>
43
+ </sl-dialog>
44
+
45
+ <div class="bind viur-shop-wrap">
46
+ <div
47
+ class="viur-shop-stepper-wrap"
48
+ :class="{ 'full-width': sidebarBottom }"
49
+ >
50
+ <slot name="main">
51
+ <sl-tab-group
52
+ class="viur-shop-order-tabgroup"
53
+ noScrollControls
54
+ @sl-tab-hide="onTabHide"
55
+ @sl-tab-show="onTabChange"
56
+ ref="tabGroup"
57
+ >
58
+ <StepperTab
59
+ v-for="(tab, index) in state.tabNames"
60
+ :key="tab"
61
+ :tab="tab"
62
+ :currentTab="state.currentTab"
63
+ :tabs="state.tabs"
64
+ :tabIdx="index"
65
+ :stepperLength="state.tabNames.length"
66
+ :disabled="
67
+ index === 0 ? false : !state.tabs[state.tabNames[index - 1]].valid
68
+ "
69
+ >
70
+ </StepperTab>
71
+
72
+ <template v-for="tab in state.tabNames" :key="tab">
73
+ <StepperItem
74
+ :tab="tab"
75
+ :currentTab="state.currentTab"
76
+ :tabs="state.tabs"
77
+ @valid="stepIsValid"
78
+ >
79
+ </StepperItem>
80
+ </template>
81
+ </sl-tab-group>
82
+ </slot>
83
+
84
+ <slot name="trigger" v-if="trigger">
85
+ <div
86
+ class="viur-shop-form-footer"
87
+ :class="{ 'flex-end': state.tabIdx === 0, 'last-row': sidebarBottom }"
88
+ v-if="state.tabIdx !== state.tabNames.length - 1"
89
+ >
90
+ <StepperTrigger
91
+ :index="state.tabIdx"
92
+ :tab="state.currentTab"
93
+ :tabs="state.tabs"
94
+ @prevTab="prevTab"
95
+ @nextTab="nextTab"
96
+ >
97
+ </StepperTrigger>
98
+ </div>
99
+ </slot>
100
+ </div>
101
+
102
+ <slot
103
+ name="sidebar"
104
+ v-if="sidebar && state.tabIdx < state.tabNames.length - 1"
105
+ >
106
+ <div class="viur-shop-sidebar-wrap" :class="{ bottom: sidebarBottom }">
107
+ <ShopSummary
108
+ :showDiscount="showDiscount"
109
+ :customShippingComponent="customShippingComponent"
110
+ >
111
+ <template #custom v-if="customComponent">
112
+ <component :is="customComponent"></component>
113
+ </template>
114
+ <template #action-buttons>
115
+ <slot name="action-buttons"></slot>
116
+ </template>
117
+ </ShopSummary>
118
+ </div>
119
+ </slot>
120
+ </div>
121
+ </template>
122
+
123
+ <script setup>
124
+ import { reactive, computed, ref, onBeforeMount, provide } from "vue";
125
+ import StepperTab from "./ui/stepper/StepperTab.vue";
126
+ import StepperItem from "./ui/stepper/StepperItem.vue";
127
+ import StepperTrigger from "./ui/stepper/StepperTrigger.vue";
128
+ import ShopSummary from "./ShopSummary.vue";
129
+ import ShopAlert from "./ui/generic/alerts/ShopAlert.vue";
130
+ import { useMessageStore } from "../stores/message";
131
+ import { useOrderStore } from "../stores/order";
132
+ import { useCartStore } from "../stores/cart";
133
+
134
+ const messageStore = useMessageStore();
135
+ const orderStore = useOrderStore();
136
+ const cartStore = useCartStore();
137
+
138
+ const props = defineProps({
139
+ tabs: {
140
+ type: Object,
141
+ required: true,
142
+ },
143
+ sidebar: {
144
+ type: Boolean,
145
+ default: true,
146
+ required: false,
147
+ },
148
+ trigger: {
149
+ type: Boolean,
150
+ default: true,
151
+ required: false,
152
+ },
153
+ sidebarBottom: {
154
+ type: Boolean,
155
+ default: false,
156
+ required: false,
157
+ },
158
+ showDiscount: {
159
+ type: Boolean,
160
+ default: true,
161
+ },
162
+ customComponent: { default: undefined },
163
+ customShippingComponent: { default: undefined },
164
+ });
165
+
166
+ const emit = defineEmits(["tabChange"]);
167
+
168
+ const state = reactive({
169
+ tabNames: computed(() => sortTabs(state.tabs)),
170
+ currentTabObj: computed(() => state.tabs[state.tabNames[state.tabIdx]]), //dont use as prop, cause of multiple rerenderings
171
+ tabIdx: 0,
172
+ currentTab: "",
173
+ tabs: {},
174
+ });
175
+ provide("stepperState", state);
176
+
177
+ const tabGroup = ref(null);
178
+ const freezeCart = ref(null);
179
+
180
+ function sortTabs(tabs) {
181
+ const sortedArray = [];
182
+ const outputArray = [];
183
+
184
+ for (const tab in tabs) {
185
+ if (tabs[tab].position) {
186
+ sortedArray.push([tab, tabs[tab].position]);
187
+ } else {
188
+ sortedArray.push([tab, 0]);
189
+ }
190
+ }
191
+
192
+ sortedArray.sort((a, b) => {
193
+ return a[1] - b[1];
194
+ });
195
+
196
+ sortedArray.forEach((tab) => {
197
+ outputArray.push(tab[0]);
198
+ });
199
+ return outputArray;
200
+ }
201
+
202
+ function onTabChange(e) {
203
+ let tab = e?.detail.name;
204
+
205
+ state.currentTab = tab;
206
+ state.tabIdx = state.tabNames.indexOf(tab);
207
+
208
+ emit("tabChange", e);
209
+ }
210
+
211
+ function onTabHide(e) {
212
+ if (state.currentTab==='cart'){
213
+ orderStore.add_or_update()
214
+ }
215
+
216
+ /*if (state.tabIdx === 0 && !cartStore.state.freeze) {
217
+ freezeCart.value.show();
218
+ }*/
219
+ }
220
+
221
+ function onFreezeCart() {
222
+ cartStore.state.freeze = true;
223
+ orderStore.handler();
224
+ freezeCart.value.hide();
225
+ }
226
+
227
+ function prevTab() {
228
+ if (state.tabIdx > 0) {
229
+ tabGroup.value.show(state.tabNames[state.tabIdx - 1]);
230
+ }
231
+ }
232
+
233
+ function nextTab() {
234
+ if (state.tabIdx < state.tabNames.length - 1) {
235
+ tabGroup.value.show(state.tabNames[state.tabIdx + 1]);
236
+ }
237
+ }
238
+
239
+ function goToStart() {
240
+ tabGroup.value.show(state.tabNames[0]);
241
+ }
242
+
243
+ function editAddress(e) {
244
+ tabGroup.value.show(e);
245
+ }
246
+
247
+ function stepIsValid(e) {
248
+ console.log("stepIsValid", e);
249
+
250
+ state.tabs[state.currentTab].valid = e;
251
+ if (cartStore.state.freeze) {
252
+ orderStore.handler();
253
+ }
254
+ }
255
+
256
+ onBeforeMount(() => {
257
+ state.tabs = { ...props.tabs }; //make reactive so we can save states to tabs
258
+
259
+ const tabNames = sortTabs(state.tabs);
260
+ state.currentTab = tabNames[0];
261
+ });
262
+ </script>
263
+
264
+ <style scoped>
265
+ * {
266
+ box-sizing: border-box;
267
+ }
268
+
269
+ .viur-shop-wrap {
270
+ --shop-sidebar-background: var(--sl-color-neutral-100);
271
+ --shop-sidebar-columns: 4;
272
+ --shop-main-columns: 8;
273
+ --shop-tab-color: var(--sl-color-neutral-400);
274
+ --shop-tab-color-active: var(--ignt-color-primary);
275
+
276
+ --shop-form-headline-size: 1.5em;
277
+ --shop-success-headline-size: var(--shop-form-headline-size);
278
+
279
+ display: grid;
280
+ grid-template-columns: repeat(12, minmax(0, 1fr));
281
+ grid-template-rows: 1fr max-content;
282
+ grid-gap: var(--ignt-spacing-2x-large);
283
+
284
+ width: 100%;
285
+ border: 0 white solid;
286
+ }
287
+
288
+ @layer foundation.shop {
289
+ .viur-shop-sidebar-wrap {
290
+ display: flex;
291
+ flex-direction: column;
292
+ background-color: var(--shop-sidebar-background);
293
+ padding: var(--sl-spacing-medium);
294
+ overflow: hidden;
295
+ border-radius: var(--sl-border-radius-medium);
296
+ grid-column: auto / span var(--shop-sidebar-columns);
297
+ /* height has to be set or sidebar grows until infinity... */
298
+ height: min-content;
299
+ @media (min-width: 1024px) {
300
+ position: sticky;
301
+ top: 2rem;
302
+ }
303
+ }
304
+
305
+ .viur-shop-stepper-wrap {
306
+ display: flex;
307
+ flex-direction: column;
308
+ grid-column: auto / span var(--shop-main-columns);
309
+
310
+ @media (max-width: 1024px) {
311
+ grid-column: auto / span 12;
312
+ }
313
+
314
+ @media (max-width: 600px) {
315
+ &::part(active-tab-indicator) {
316
+ display: none;
317
+ }
318
+ }
319
+ }
320
+
321
+ .viur-shop-form-footer {
322
+ height: fit-content;
323
+
324
+ /* TODO: sticky Trigger yes no? */
325
+ /* position: sticky;
326
+ bottom: 2rem; */
327
+ }
328
+
329
+ :deep(.viur-shop-form-footer) {
330
+ display: flex;
331
+ justify-content: space-between;
332
+ margin-top: var(--sl-spacing-large);
333
+ }
334
+
335
+ .flex-end {
336
+ justify-content: flex-end;
337
+ }
338
+
339
+ .bottom {
340
+ grid-column: auto / span 12;
341
+ grid-row-start: 2;
342
+ }
343
+
344
+ .full-width {
345
+ grid-column: auto / span 12;
346
+ }
347
+
348
+ .last-row {
349
+ grid-row-start: 3;
350
+ }
351
+ }
352
+ </style>
@@ -0,0 +1,113 @@
1
+ <template>
2
+
3
+ <loading-handler :isLoading="paymentStore.state.isLoading"
4
+ :isUpdating="paymentStore.state.isUpdating"
5
+ :hasError="paymentStore.state.hasError"
6
+ :errorMessage="paymentStore.state.errorMessage">
7
+
8
+ <PaymentSelector :options="state.options" @valid="checkPaymentIsValid">
9
+
10
+ </PaymentSelector>
11
+
12
+ </loading-handler>
13
+
14
+ <div v-if="paymentStore.state.paymentSelection?.[0].startsWith('unzer-')">
15
+ <unzer-payment></unzer-payment>
16
+ </div>
17
+ </template>
18
+ <script setup>
19
+ import {useCartStore} from "../stores/cart";
20
+ import {usePaymentStore} from "../stores/payment"
21
+ import {onBeforeMount, reactive,computed, watch} from "vue";
22
+ import LoadingHandler from "./generic/loadinghandler.vue"
23
+ import CardSelector from "./ui/generic/CardSelector.vue"
24
+ import unzerPayment from './paymentProvider/unzerPayment.vue'
25
+
26
+ import PaymentSelector from "./ui/payment/PaymentSelector.vue";
27
+
28
+
29
+ const cartStore = useCartStore();
30
+ const paymentStore = usePaymentStore()
31
+ const emits = defineEmits(['valid'])
32
+ const props = defineProps({
33
+ })
34
+
35
+
36
+ let iconMap = {
37
+ 'prepayment':'currency-euro',
38
+ 'unzer-card':'credit-card-2-back-fill',
39
+ 'unzer-paypal':'paypal',
40
+ 'unzer-ideal':'bank2',
41
+ 'unzer-sofort':'cash-coin'
42
+ }
43
+
44
+ let simpleProviders = [
45
+ 'prepayment',
46
+ 'unzer-paypal',
47
+ 'unzer-sofort'
48
+ ]
49
+
50
+ const state = reactive({
51
+ selection:null,
52
+ selectionValid:false,
53
+ options:computed(()=>{
54
+ let options = []
55
+ let option = {
56
+ paymenttype:null,
57
+ widget:"default",
58
+ name:null,
59
+ description:null,
60
+ icon:null
61
+
62
+ }
63
+
64
+ for (const provider of paymentStore.state.paymentProviders){
65
+ let currentOption = {...option}
66
+ currentOption.paymenttype = provider[0]
67
+ currentOption.name = provider[1]['title']
68
+ currentOption.description = provider[1]['descr']
69
+ currentOption.icon = iconMap[provider[0]]
70
+ if (simpleProviders.includes(provider[0])){
71
+ currentOption.widget = "simple"
72
+ }
73
+
74
+ options.push(currentOption)
75
+ }
76
+
77
+
78
+ return options
79
+ })
80
+ })
81
+
82
+
83
+ //await orderStore.startCheckout()
84
+ // > on weiter
85
+
86
+ async function updatePaymentProvider(selection){
87
+ let update = paymentStore.updateOrder()
88
+ if (update){
89
+ emits("valid", true)
90
+ }
91
+ }
92
+
93
+ function checkPaymentIsValid(selection) {
94
+ console.log(selection)
95
+ state.selectionValid = selection
96
+ }
97
+
98
+
99
+ onBeforeMount(async () => {
100
+ await paymentStore.initPayment()
101
+ console.log("AAA")
102
+ const script = document.createElement('script');
103
+ script.src = 'https://static.unzer.com/v1/unzer.js';
104
+ script.addEventListener('error', e => console.log(e.error));
105
+ document.head.appendChild(script);
106
+ console.log("BBBB")
107
+ });
108
+
109
+ </script>
110
+
111
+ <style scoped>
112
+
113
+ </style>
@@ -0,0 +1,52 @@
1
+ <template>
2
+ <loading-handler :isLoading="shippingStore.state.isLoading"
3
+ :isUpdating="shippingStore.state.isUpdating"
4
+ :hasError="shippingStore.state.hasError"
5
+ :errorMessage="shippingStore.state.errorMessage">
6
+
7
+ <card-selector :options="shippingStore.state.shippingData"
8
+ v-model:selection="shippingStore.state.selectedShippingMethod"
9
+ @change="updateShippingMethod"
10
+ >
11
+ <template v-slot="{option, index}">
12
+ <img slot="image">
13
+ {{ option['dest']['name'] }}
14
+ <div slot="footer">
15
+ Lieferzeit: {{ option['dest']['delivery_time_range'] }}
16
+ </div>
17
+ </template>
18
+ </card-selector>
19
+ </loading-handler>
20
+ </template>
21
+ <script setup>
22
+ import {useCartStore} from "../stores/cart";
23
+ import {useShippingStore} from "../stores/shipping"
24
+ import {onBeforeMount, reactive,computed, watch} from "vue";
25
+ import LoadingHandler from "./generic/loadinghandler.vue"
26
+ import CardSelector from "./ui/generic/CardSelector.vue"
27
+
28
+ const cartStore = useCartStore();
29
+ const shippingStore = useShippingStore()
30
+ const emits = defineEmits(['valid'])
31
+ const props = defineProps({
32
+ })
33
+
34
+ const state = reactive({
35
+ })
36
+
37
+ onBeforeMount(async () => {
38
+ await shippingStore.initShipping()
39
+ });
40
+
41
+ async function updateShippingMethod(selection){
42
+ let update = await shippingStore.updateCart()
43
+ if (update){
44
+ emits("valid", true)
45
+ }
46
+ }
47
+
48
+ </script>
49
+
50
+ <style scoped>
51
+
52
+ </style>
@@ -0,0 +1,138 @@
1
+ <template>
2
+ <h2 class="viur-shop-cart-sidebar-headline headline">Zusammenfassung</h2>
3
+ <br />
4
+ <div class="viur-shop-cart-sidebar-info-line">
5
+ <span>Zwischensumme</span>
6
+
7
+ <sl-format-number
8
+ lang="de"
9
+ type="currency"
10
+ currency="EUR"
11
+ :value="state.node?.total"
12
+ >
13
+ </sl-format-number>
14
+ <br />
15
+ </div>
16
+ <div class="viur-shop-cart-sidebar-info-line">
17
+ <span>Rabatt</span>
18
+
19
+ <sl-format-number
20
+ lang="de"
21
+ type="currency"
22
+ currency="EUR"
23
+ :value="state.node?.discount ? state.node.discount : 0"
24
+ >
25
+ </sl-format-number>
26
+ </div>
27
+ <div class="viur-shop-cart-sidebar-info-line">
28
+ <shipping-info ref="shipping">
29
+ <template #custom v-if="customShippingComponent">
30
+ <component :is="customShippingComponent"></component>
31
+ </template>
32
+ </shipping-info>
33
+ </div>
34
+ <div class="viur-shop-cart-sidebar-info-line total">
35
+ <span>Gesamt:</span>
36
+ <sl-format-number
37
+ lang="de"
38
+ type="currency"
39
+ currency="EUR"
40
+ :value="totalPrice"
41
+ >
42
+ </sl-format-number>
43
+ <!-- TODO: Some project needs "VAT included" here -->
44
+ </div>
45
+ <!-- TODO: Placement of discount? -->
46
+ <div class="viur-shop-discount-wrap" v-if="showDiscount">
47
+ <Discount></Discount>
48
+ </div>
49
+
50
+ <slot name="action-buttons">
51
+ <div class="viur-shop-cart-sidebar-btn-wrap">
52
+ <sl-button variant="primary" size="medium"> Jetzt Bestellen</sl-button>
53
+ <sl-button size="medium" variant="info">
54
+ <sl-icon name="paypal" slot="prefix"></sl-icon>
55
+ Paypal
56
+ </sl-button>
57
+ </div>
58
+ </slot>
59
+ </template>
60
+
61
+ <script setup>
62
+ import Discount from "./cart/Discount.vue";
63
+ import ShippingInfo from "./ui/generic/ShippingInfo.vue";
64
+ import { computed, onBeforeMount, reactive, ref } from "vue";
65
+ import { useCartStore } from "../stores/cart";
66
+ import { useShippingStore } from "../stores/shipping";
67
+ import { useOrderStore } from "../stores/order";
68
+
69
+ const props = defineProps({
70
+ showDiscount: { type: Boolean, default: true },
71
+ customShippingComponent: { type: Object, default: undefined },
72
+ });
73
+
74
+ const cartStore = useCartStore();
75
+ const shippingStore = useShippingStore();
76
+ const orderStore = useOrderStore();
77
+
78
+ const shipping = ref(null);
79
+
80
+ const state = reactive({
81
+ node: computed(() => cartStore.state.basket),
82
+ });
83
+
84
+ const totalPrice = computed(() => {
85
+ if (shippingStore.state.selectedShippingMethod) {
86
+ return (
87
+ state.node.total +
88
+ shippingStore.state.selectedShippingMethod?.dest.shipping_cost -
89
+ state.node.discount
90
+ );
91
+ } else {
92
+ if (Object.keys(cartStore.state.childrenByNode).includes(state.node.key)) {
93
+ return (
94
+ state.node?.total +
95
+ shippingStore.state.selectedShippingMethod?.dest.shipping_cost -
96
+ state.node.discount
97
+ );
98
+ } else {
99
+ return state.node.total + 0 - state.node.discount; //kein shipping
100
+ }
101
+ }
102
+ });
103
+ </script>
104
+
105
+ <style>
106
+ .viur-shop-cart-sidebar-info-line {
107
+ display: flex;
108
+ flex-direction: row;
109
+ flex-wrap: nowrap;
110
+ margin: var(--sl-spacing-2x-small) 0;
111
+
112
+ &.total {
113
+ font-weight: 600;
114
+ border-top: 1px solid var(--sl-color-neutral-300);
115
+ border-bottom: 1px solid var(--sl-color-neutral-300);
116
+ padding: var(--sl-spacing-x-small) 0;
117
+ margin: var(--sl-spacing-small) 0;
118
+ }
119
+
120
+ span {
121
+ margin-right: auto;
122
+ }
123
+ }
124
+
125
+ .viur-shop-cart-sidebar-btn-wrap {
126
+ display: flex;
127
+ flex-direction: column;
128
+ margin-top: var(--sl-spacing-large);
129
+
130
+ sl-button {
131
+ margin-bottom: var(--sl-spacing-x-small);
132
+ }
133
+ }
134
+
135
+ .viur-shop-cart-sidebar-headline {
136
+ margin: 0 0 var(--sl-spacing-large) 0;
137
+ }
138
+ </style>