@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,132 @@
1
+ <template>
2
+ <sl-tab
3
+ class="viur-shop-order-tab"
4
+ slot="nav"
5
+ :panel="tab"
6
+ :disabled="!shopStore.state.tabs[tab]['active']"
7
+ @click="shopStore.navigateToTab(tab)"
8
+ >
9
+ <div class="viur-shop-order-step">
10
+ <sl-icon
11
+ class="viur-shop-order-step-icon"
12
+ v-if="shopStore.state.tabs[tab]?.icon?.name"
13
+ :name="shopStore.state.tabs[tab].icon.name"
14
+ :library="shopStore.state.tabs[tab].icon.library ? shopStore.state.tabs[tab].icon.library : 'default'"
15
+ >
16
+ </sl-icon>
17
+
18
+ <div class="viur-shop-order-status-text">
19
+ <template v-if="tab && shopStore.state.tabs[tab]">
20
+ {{ shopStore.state.tabIndexMap[tab] + 1 }}.
21
+ <span class="viur-shop-order-status-span">
22
+ {{ shopStore.state.tabs[tab]?.displayName }}
23
+ </span>
24
+ </template>
25
+ <template v-else>
26
+ {{ tab }}
27
+ </template>
28
+ </div>
29
+ </div>
30
+
31
+ <sl-icon
32
+ name="chevron-right"
33
+ class="viur-shop-order-tab-check"
34
+ v-if="shopStore.state.tabIndexMap[tab] < shopStore.state.stepperLength - 1"
35
+ >
36
+ </sl-icon>
37
+ </sl-tab>
38
+ </template>
39
+
40
+ <script setup>
41
+ import { watch, onBeforeMount, inject } from "vue";
42
+ import {useViurShopStore} from '../shop'
43
+ const shopStore = useViurShopStore()
44
+
45
+ const props = defineProps({
46
+ tab: {
47
+ type: String,
48
+ required: true,
49
+ default:"-"
50
+ }
51
+ });
52
+ </script>
53
+
54
+ <style scoped>
55
+ .viur-shop-order-tab {
56
+ width: 25%;
57
+ position: relative;
58
+
59
+ &::part(base) {
60
+ color: var(--shop-tab-color);
61
+ display: flex;
62
+ height: 100%;
63
+ }
64
+
65
+ &[aria-selected="true"] {
66
+ --shop-tab-color: var(--shop-tab-color--active);
67
+ }
68
+
69
+ @media (max-width: 900px) {
70
+ &::part(base) {
71
+ height: 100%;
72
+ padding: var(--sl-spacing-small) var(--sl-spacing-medium);
73
+ }
74
+ }
75
+
76
+ @media (max-width: 600px) {
77
+ &[aria-selected="true"] {
78
+ width: 100%;
79
+ }
80
+
81
+ &:not([aria-selected="true"]) {
82
+ .viur-shop-order-status-span {
83
+ display: none;
84
+ }
85
+ }
86
+ }
87
+ }
88
+
89
+ .viur-shop-order-step {
90
+ width: 100%;
91
+ height: 100%;
92
+ display: flex;
93
+ flex-direction: column;
94
+ justify-content: center;
95
+ align-items: center;
96
+
97
+ &:has(sl-icon) {
98
+ justify-content: flex-start;
99
+ }
100
+
101
+ sl-icon {
102
+ font-size: 2.5em;
103
+ margin-bottom: 15px;
104
+ }
105
+
106
+ @media (max-width: 900px) {
107
+ justify-content: center;
108
+
109
+ sl-icon {
110
+ display: none;
111
+ }
112
+ }
113
+ }
114
+
115
+ .viur-shop-order-status-text {
116
+ font-size: 1em;
117
+ color: inherit;
118
+ text-align: center;
119
+ white-space: initial;
120
+ }
121
+
122
+ .viur-shop-order-tab-check {
123
+ position: absolute;
124
+ right: -0.5em;
125
+
126
+ @media (max-width: 900px) {
127
+ font-size: 0.7em;
128
+ right: -0.35em;
129
+ top: calc(50% - 0.35em);
130
+ }
131
+ }
132
+ </style>
@@ -0,0 +1,49 @@
1
+ <template>
2
+ <sl-button v-bind="$attrs" @click="state.opened=true">
3
+ <slot>
4
+
5
+ </slot>
6
+ </sl-button>
7
+ <teleport to="#dialogs" v-if="state.opened">
8
+ <sl-dialog :open="state.opened" @sl-after-hide="state.opened=false" noHeader>
9
+ <slot name="dialog" :close="close">
10
+
11
+ </slot>
12
+ </sl-dialog>
13
+ </teleport>
14
+ </template>
15
+
16
+ <script setup>
17
+ import {reactive} from 'vue'
18
+ defineOptions({
19
+ inheritAttrs: false
20
+ })
21
+
22
+ const state = reactive({
23
+ opened:false
24
+ })
25
+
26
+ function close(){
27
+ state.opened=false
28
+ }
29
+
30
+ </script>
31
+
32
+ <style scoped>
33
+
34
+ .decent{
35
+ margin: 0;
36
+ transition: all ease .3s;
37
+
38
+ &::part(base){
39
+ border: none;
40
+ }
41
+
42
+ &::part(label){
43
+ padding: 0;
44
+ height: var(--sl-input-height-medium);
45
+ width: calc(var(--sl-input-height-medium) / 5 * 4);
46
+ }
47
+ }
48
+
49
+ </style>
@@ -0,0 +1,95 @@
1
+ import {reactive,ref, computed} from 'vue'
2
+ import { useOrder } from '../composables/order';
3
+ import { useCart } from '../composables/cart';
4
+ import { useViurShopStore } from '../shop'
5
+ import { defineStore } from "pinia";
6
+ export const useAddress = defineStore("useAddressStore", () => {
7
+ const shopStore = useViurShopStore()
8
+
9
+ const state = reactive({
10
+ billingIsShipping:true,
11
+ shippingForm:ref(null),
12
+ // for shipping and both mode
13
+ shippingIsLoading:computed(()=>{
14
+ if (!state.shippingForm){
15
+ return true
16
+ }
17
+ return state.shippingForm.state.loading
18
+ }),
19
+ shippingIsUpdating:false, // for shipping and both mode
20
+ shippingData:{},
21
+ shippingValid:computed(()=>{
22
+ if(shopStore.state.cartRoot?.['shipping_address']){
23
+ return true
24
+ }
25
+ return false
26
+ }),
27
+
28
+ billingForm:ref(null),
29
+ billingIsLoading:computed(()=>{
30
+ if (!state.billingForm){
31
+ return true
32
+ }
33
+ return state.billingForm.state.loading
34
+ }),
35
+ billingIsUpdating:false,
36
+ billingData:{},
37
+ billingValid:computed(()=>{
38
+ if( shopStore.state.order?.['billing_address']){
39
+ return true
40
+ }
41
+ return false
42
+ })
43
+
44
+ })
45
+
46
+ function saveForm(type,shippingIsBilling=false){
47
+ state[`${type}IsUpdating`] = true
48
+ return state[`${type}Form`].sendData().then(async (resp)=>{
49
+ let data = await resp.json()
50
+ if (['addSuccess','editSuccess'].includes(data['action'])){
51
+ state[`${type}Data`] = data['values']
52
+ await updateAddresses(type, shippingIsBilling)
53
+ }
54
+ state[`${type}IsUpdating`] = undefined
55
+ return data
56
+ })
57
+ }
58
+
59
+ function saveAddresses(shippingIsBilling=false){
60
+ if (shippingIsBilling) {
61
+ return saveForm('shipping',shippingIsBilling)
62
+ }else{
63
+ return new Promise((resolve, reject) => {
64
+ saveForm('shipping').then(()=>{
65
+ saveForm('billing').then(()=>{
66
+ resolve({'actions':'editSuccess'})
67
+ }).catch((e)=>reject(e))
68
+ }).catch((e)=>reject(e))
69
+ })
70
+ }
71
+ }
72
+
73
+ async function updateAddresses(type, shippingIsBilling=false) {
74
+ let key = state[`${type}Data`]['key']
75
+
76
+ if (type === 'shipping'){
77
+ const {updateCart} = useCart()
78
+ updateCart({shipping_address_key:key})
79
+ if(shippingIsBilling){
80
+ const {addOrUpdateOrder} = useOrder()
81
+ await addOrUpdateOrder({billing_address_key:key})
82
+ }
83
+ }else if (type === 'billing'){
84
+ const {addOrUpdateOrder} = useOrder()
85
+ await addOrUpdateOrder({billing_address_key:key})
86
+ }
87
+ }
88
+
89
+ return {
90
+ state,
91
+ saveForm,
92
+ updateAddresses,
93
+ saveAddresses
94
+ }
95
+ })
@@ -0,0 +1,132 @@
1
+ import {reactive} from 'vue'
2
+ import {Request} from '@viur/vue-utils'
3
+ import { removeUndefinedValues} from '../utils'
4
+
5
+ import { useViurShopStore } from '../shop'
6
+
7
+ export function useCart() {
8
+ const shopStore = useViurShopStore()
9
+ const state = reactive({
10
+ isLoading:false,
11
+ isUpdating:false
12
+ })
13
+
14
+ function getValue(value){
15
+ if (value !== null &&
16
+ typeof value === 'object' &&
17
+ !Array.isArray(value) &&
18
+ Object.keys(value).includes(shopStore.state.language)
19
+ ){
20
+ return value[shopStore.state.language]
21
+ }
22
+ return value
23
+ }
24
+
25
+ //agtha3ZpdXIzdGVzdHIgCxITZ3JlZW5zaG9wX2NhcnRfbm9kZRiAgIDE29eVCgw
26
+ function createCart(){
27
+ Request.post(shopStore.state.shopApiUrl+'/cart_add',{dataObj:{
28
+ parent_cart_key:shopStore.state.cartRoot['key'],
29
+ cart_type:"wishlist"
30
+ }}).then(async( resp)=>{
31
+ let data = await resp.json()
32
+ console.log(data)
33
+ })
34
+
35
+
36
+ }
37
+
38
+
39
+ function fetchCart(){
40
+ //first fetch root then fetchItems for this root
41
+ state.isLoading = true
42
+ return fetchCartRoot().then(()=>{
43
+ if(!shopStore.state.cartRoot?.['key']) return 0
44
+ fetchCartItems(shopStore.state.cartRoot['key']).then(()=>{
45
+ state.isLoading = false
46
+ shopStore.state.cartReady = true
47
+ })
48
+ })
49
+ }
50
+
51
+ function fetchCartRoot(){
52
+ // fetch list of Rootnodes and saves the first one
53
+
54
+ return Request.get(`${shopStore.state.shopUrl}/cart/listRootNodes`).then(async (resp)=>{
55
+ let data = await resp.json()
56
+ shopStore.state.cartRoot = data.filter(i=>i['cart_type']==='basket')?.[0] ? data.filter(i=>i['cart_type']==='basket')[0]:[]
57
+ })
58
+ }
59
+
60
+ function fetchCartItems(key, parentKey=null){
61
+ //fetch cart items
62
+ return Request.get(`${shopStore.state.shopApiUrl}/cart_list`,{dataObj:{
63
+ cart_key:key
64
+ }}).then(async( resp) =>{
65
+ let data = await resp.json()
66
+ shopStore.state.cartList=data
67
+ })
68
+ }
69
+
70
+ function updateCart({
71
+ cart_type,
72
+ name,
73
+ customer_comment,
74
+ shipping_address_key,
75
+ shipping_key,
76
+ discount_key,
77
+ } = {}){
78
+
79
+ let data= {
80
+ cart_type:cart_type?cart_type:shopStore.state.cartRoot['cart_type'],
81
+ name:name?name:shopStore.state.cartRoot['name'],
82
+ customer_comment:customer_comment?customer_comment:shopStore.state.cartRoot['customer_comment'],
83
+ shipping_address_key:shipping_address_key?shipping_address_key:shopStore.state.cartRoot?.['shipping_address']?.['dest']?.['key'],
84
+ shipping_key:shipping_key?shipping_key:shopStore.state.cartRoot?.['shipping']?.['dest']?.['key'],
85
+ discount_key:discount_key?discount_key:shopStore.state.cartRoot?.['discount']?.['dest']?.['key'],
86
+ cart_key:shopStore.state.cartRoot['key']
87
+ }
88
+
89
+ return Request.post(`${shopStore.state.shopApiUrl}/cart_update`, {
90
+ dataObj: removeUndefinedValues(data)
91
+ }).then(async (resp)=>{
92
+ fetchCart()
93
+ })
94
+ }
95
+
96
+ function addItem(key, quantity=1, cart=null, quantity_mode='replace'){
97
+ //add Item to cart
98
+ state.isUpdating = true
99
+ return Request.post(`${shopStore.state.shopApiUrl}/article_add`, {dataObj:{
100
+ article_key: key,
101
+ parent_cart_key:cart?cart:shopStore.state.cartRoot['key'],
102
+ quantity:quantity,
103
+ quantity_mode:quantity_mode
104
+ }}).then(async (resp)=>{
105
+ state.isUpdating=false
106
+ fetchCart()
107
+ })
108
+
109
+ }
110
+ function removeItem(key, cart=null){
111
+ state.isUpdating = true
112
+ return Request.post(`${shopStore.state.shopApiUrl}/article_remove`, {dataObj:{
113
+ article_key: key,
114
+ parent_cart_key:cart?cart:shopStore.state.cartRoot['key']
115
+ }}).then(async (resp)=>{
116
+ state.isUpdating=false
117
+ fetchCart()
118
+ })
119
+ }
120
+
121
+ return {
122
+ state,
123
+ fetchCartRoot,
124
+ fetchCartItems,
125
+ fetchCart,
126
+ updateCart,
127
+ addItem,
128
+ removeItem,
129
+ createCart,
130
+ getValue
131
+ }
132
+ }
@@ -0,0 +1,80 @@
1
+ import {reactive} from 'vue'
2
+ import {Request} from '@viur/vue-utils'
3
+ import { useViurShopStore } from '../shop'
4
+ import { removeUndefinedValues} from '../utils'
5
+ import { useUrlSearchParams } from '@vueuse/core'
6
+
7
+ export function useOrder() {
8
+ const state = reactive({
9
+ isLoading:false,
10
+ isUpdating:false
11
+ })
12
+ const shopStore = useViurShopStore()
13
+ function updateOrderState(key,data){
14
+ shopStore.state.order = data
15
+ shopStore.state.orderKey = key
16
+
17
+ const params = useUrlSearchParams('hash')
18
+ params['order'] = shopStore.state.orderKey
19
+
20
+ }
21
+ function fetchOrder(key){
22
+ state.isLoading = true
23
+ return Request.post(shopStore.state.shopApiUrl+"/order_view",{dataObj:{
24
+ "order_key": key
25
+ }}).then(async (resp)=>{
26
+ let data = await resp.json()
27
+ updateOrderState(data['skel']['key'], data['skel'])
28
+ shopStore.state.canCheckout = data["can_checkout"]
29
+ shopStore.state.canOrder = data["can_order"]
30
+ state.isLoading = false
31
+ }).catch((error)=>{
32
+ shopStore.state.order = null
33
+ shopStore.state.orderKey = null
34
+ state.isLoading = false
35
+ })
36
+ }
37
+
38
+ function addOrUpdateOrder({
39
+ payment_provider,
40
+ billing_address_key,
41
+ email,
42
+ customer_key,
43
+ state_ordered,
44
+ state_paid,
45
+ state_rts
46
+ }={}){
47
+ state.isUpdating=true
48
+ let url = shopStore.state.shopApiUrl+"/order_add"
49
+ let data = {
50
+ payment_provider:payment_provider?payment_provider:shopStore.state.order?.['payment_provider'],
51
+ billing_address_key:billing_address_key?billing_address_key:shopStore.state.order?.['billing_address_key']?.['dest']?.['key'],
52
+ email:email?email:shopStore.state.order?.['email'],
53
+ customer_key:customer_key?customer_key:shopStore.state.order?.['customer_key']?.['dest']?.['key'],
54
+ state_ordered:state_ordered?state_ordered:shopStore.state.order?.['state_ordered'],
55
+ state_paid:state_paid?state_paid:shopStore.state.order?.['state_paid'],
56
+ state_rts:state_rts?state_rts:shopStore.state.order?.['state_rts']
57
+ }
58
+ if (shopStore.state.orderKey){
59
+ url = shopStore.state.shopApiUrl+"/order_update"
60
+ data["order_key"] = shopStore.state.orderKey
61
+
62
+ }else{
63
+ data["cart_key"] = shopStore.state.cartRoot['key']
64
+ }
65
+ return Request.post(url,{dataObj:removeUndefinedValues(data)}).then(async(resp)=>{
66
+ let data = await resp.json()
67
+ updateOrderState(data['key'], data)
68
+ state.isUpdating=false
69
+ }).then(async ( resp)=>{
70
+ fetchOrder(shopStore.state.orderKey)
71
+ return resp
72
+ })
73
+ }
74
+
75
+ return {
76
+ state,
77
+ fetchOrder,
78
+ addOrUpdateOrder
79
+ }
80
+ }
@@ -0,0 +1,75 @@
1
+ import {reactive} from 'vue'
2
+ import {Request} from '@viur/vue-utils'
3
+ import { removeUndefinedValues} from '../utils'
4
+ import { useViurShopStore } from '../shop'
5
+ import {defineStore} from "pinia";
6
+
7
+ export const usePayment = defineStore("usePaymentStore", () => {
8
+ const shopStore = useViurShopStore()
9
+
10
+ const iconMap = {
11
+ 'prepayment':'currency-euro',
12
+ 'unzer-card':'credit-card-2-back-fill',
13
+ 'unzer-paypal':'paypal',
14
+ 'unzer-ideal':'bank2',
15
+ 'unzer-sofort':'cash-coin'
16
+ }
17
+
18
+ const simpleProviders = [
19
+ 'prepayment',
20
+ 'unzer-paypal',
21
+ 'unzer-sofort'
22
+ ]
23
+
24
+ const state = reactive({
25
+ isLoading:false,
26
+ isUpdating:false,
27
+ paymentData:[]
28
+ })
29
+
30
+ function _convertPayment(paymentProviders){
31
+ paymentProviders = Object.entries(paymentProviders)
32
+ let options = []
33
+ let option = {
34
+ paymenttype:null,
35
+ widget:"default",
36
+ name:null,
37
+ description:null,
38
+ icon:null
39
+
40
+ }
41
+
42
+ for (const provider of paymentProviders){
43
+ let currentOption = {...option}
44
+ currentOption.paymenttype = provider[0]
45
+ currentOption.name = provider[1]['title']
46
+ currentOption.description = provider[1]['descr']
47
+ currentOption.icon = iconMap[provider[0]]
48
+ currentOption.widget = "simple"
49
+ // if (simpleProviders.includes(provider[0])){
50
+ // currentOption.widget = "simple" // payment provider musst be initialized later
51
+ //}
52
+
53
+ options.push(currentOption)
54
+ }
55
+
56
+
57
+ return options
58
+ }
59
+
60
+ function fetchPaymentData() {
61
+ state.isLoading = true
62
+ return Request.get(`${shopStore.state.shopUrl}/order/payment_providers_list`).then(async (resp)=>{
63
+ let data = await resp.json()
64
+ state.paymentData = _convertPayment(data)
65
+ state.isLoading = false
66
+ })
67
+ }
68
+
69
+
70
+ return {
71
+ state,
72
+ fetchPaymentData
73
+
74
+ }
75
+ })
@@ -0,0 +1,32 @@
1
+ import {reactive} from 'vue'
2
+ import {Request} from '@viur/vue-utils'
3
+ import { removeUndefinedValues} from '../utils'
4
+
5
+ import { useViurShopStore } from '../shop'
6
+
7
+ export function useShipping() {
8
+ const shopStore = useViurShopStore()
9
+ const state = reactive({
10
+ isLoading:false,
11
+ isUpdating:false,
12
+ shippingData:[]
13
+ })
14
+
15
+ function fetchShippingData() {
16
+ state.isLoading = true
17
+ Request.get(`${shopStore.state.shopApiUrl}/shipping_list`,{dataObj:{
18
+ cart_key: shopStore.state.cartRoot['key']
19
+ }}).then(async (resp)=>{
20
+ let data = await resp.json()
21
+ state.shippingData = data
22
+ state.isLoading = false
23
+ })
24
+ }
25
+
26
+
27
+ return {
28
+ state,
29
+ fetchShippingData
30
+
31
+ }
32
+ }
package/src/main.js CHANGED
@@ -1,50 +1,44 @@
1
1
  // imports
2
2
  import { createPinia } from "pinia";
3
3
  import { createI18n } from "vue-i18n";
4
- import {
5
- de_translations,
6
- en_translations,
7
- } from "@viur/vue-components/translations/translations";
4
+ import { getTranslations } from "./utils";
5
+ import { de_translations, en_translations } from "@viur/vue-utils";
6
+ import en from "./translations/en"
7
+ import de from "./translations/de"
8
8
 
9
- import { useCartStore } from "./stores/cart";
10
- import createRouterInstance from "./router/index";
11
- import CartNode from "./components/cart/CartNode.vue";
12
- import CartLeaf from "./components/cart/CartLeaf.vue";
13
- // import { createApp } from "vue";
14
- // import bone from "@viur/vue-utils/bones/edit/bone.vue";
15
- // import Wrapper_nested from "@viur/vue-utils/bones/edit/wrapper_nested.vue";
9
+ export { default as ViurShop } from "./Shop.vue";
16
10
 
17
- export { useCartStore, createRouterInstance };
18
-
19
- // export all main components
20
- export { default as ShopOrderStepper } from "./components/ShopOrderStepper.vue";
21
- export { default as ShopUserData } from "./components/ShopUserData.vue";
11
+ const ViurShopComponents = {
12
+ async install(app,options) {
22
13
 
23
- export { default as CartView } from "./components/cart/CartView.vue";
24
- export { default as ExampleUsage } from "./components/order/process/ExampleUsage.vue";
25
- export { default as ConfirmView } from "./components/ShopOrderConfirm.vue";
26
- export { default as OrderComplete } from "./components/ShopOrderComplete.vue";
27
- // export { default as UserInformation } from "./components/order/information/UserInformation.vue";
28
- // export { default as UserInfoMulti } from "./components/order/information/UserInfoMulti.vue";
29
- export { default as SelectPaymentProvider } from "./components/order/process/SelectPaymentProvider.vue";
14
+ let defaultLocale = options?.defaultLocale?options.defaultLocale:'de'
15
+ let locale = options?.locale?options.locale:['de']
16
+ let fallback = options?.fallback?options.fallback:'en'
17
+ app.use(createPinia());
30
18
 
31
- const pinia = createPinia();
32
- const i18n = createI18n({
33
- locale: "de",
34
- fallbackLocale: "en",
35
- messages: {
36
- en: { ...en_translations },
37
- de: { ...de_translations },
38
- },
39
- });
19
+ let messages = {}
20
+ // fetch translations from server
21
+ let data = await getTranslations(locale)
22
+ for(const loc of locale){
23
+ if (loc === 'de'){
24
+ messages[loc] = {...data[loc], ...de_translations, ...de}
25
+ }else if (loc === 'en'){
26
+ messages[loc] = {...data[loc], ...en_translations, ...en}
27
+ }else{
28
+ messages[loc] = {...data[loc]}
29
+ }
30
+ }
40
31
 
41
- // Create a plugin to install all components
42
- const ViurShopComponents = {
43
- install(app) {
44
- app.use(pinia);
45
- app.use(i18n);
32
+ // server_translations will be overwritten by utils. Both are overwritten by local shop translations
33
+ app.use(
34
+ createI18n({
35
+ locale: defaultLocale,
36
+ fallbackLocale: fallback,
37
+ messages: messages,
38
+ })
39
+ );
46
40
  },
47
41
  };
48
42
 
49
43
  // Export the plugin as default
50
- export default ViurShopComponents;
44
+ export default ViurShopComponents;