@viur/shop-components 0.1.20 → 0.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viur/shop-components",
3
- "version": "0.1.20",
3
+ "version": "0.2.0",
4
4
  "description": "Frontend Vue components for the shop module of ViUR",
5
5
  "repository": {
6
6
  "type": "git",
package/src/Shop.vue CHANGED
@@ -3,7 +3,7 @@
3
3
  <div class="viur-shop-stepper-wrap"
4
4
  :class="{ 'full-width': (!summary || summary==='bottom' || shopStore.state.currentTab==='complete') }"
5
5
  >
6
- <shop-order-stepper>
6
+ <shop-order-stepper >
7
7
  <template #template_cart>
8
8
  <slot name="template_cart"></slot>
9
9
  </template>
@@ -110,7 +110,7 @@ const state = reactive({
110
110
  onBeforeMount(()=>{
111
111
  getTranslations([props.language], "viur.shop.*").then((resp)=>{
112
112
  state.translationsLoaded = true
113
- })
113
+ })
114
114
  shopStore.state.language = props.language
115
115
  shopStore.state.showNodes = props.showCartNodes
116
116
  shopStore.state.debug = props.debug
@@ -5,7 +5,7 @@
5
5
  ref="stepper"
6
6
  >
7
7
  <template v-for="(tab,name) in shopStore.state.tabs">
8
- <StepperTab
8
+ <StepperTab v-show="shopStore.state.currentTab!=='complete'"
9
9
  :tab="name"
10
10
  >
11
11
  </StepperTab>
@@ -89,26 +89,7 @@ onMounted(()=>{
89
89
  })
90
90
 
91
91
  function nextStep(obj){
92
- shopStore.state.tabs[shopStore.state.currentTab]['valid']=false
93
- shopStore.state.tabs[shopStore.state.currentTab]['validating']=true
94
- //validate step, like send forms or something like this
95
- Promise.resolve(obj.nextfunction()).then((resp)=>{
96
- if (resp){
97
- shopStore.state.tabs[shopStore.state.currentTab]['valid']=true
98
- shopStore.state.tabs[shopStore.state.currentTab]['validating']=false
99
- useTimeoutFn(() => {
100
- shopStore.navigateToNext()
101
- }, 300)
102
-
103
- }else{
104
- shopStore.state.tabs[shopStore.state.currentTab]['valid']=false
105
- shopStore.state.tabs[shopStore.state.currentTab]['validating']=false
106
- }
107
- }).catch(error=>{
108
- shopStore.state.tabs[shopStore.state.currentTab]['valid']=false
109
- shopStore.state.tabs[shopStore.state.currentTab]['validating']=false
110
- })
111
- console.log("----")
92
+ shopStore.tabValidation(obj.nextfunction, shopStore.navigateToNext)
112
93
  }
113
94
 
114
95
  function active(obj){
@@ -27,16 +27,6 @@
27
27
  <sl-format-number lang="de" type="currency" currency="EUR" :value="state.shippingTotal">
28
28
  </sl-format-number>
29
29
  </div>
30
- <div class="viur-shop-cart-sidebar-info viur-shop-cart-shipping-item" v-if="shopStore.state.order?.cart?.dest?.shipping">
31
- <span v-html="$t('viur.shop.summary_delivery_time')"></span>
32
- <span>
33
- {{
34
- shopStore.state.order?.cart?.dest?.shipping?.dest?.delivery_time_range ?
35
- shopStore.state.order?.cart?.dest?.shipping?.dest?.delivery_time_range :
36
- 0
37
- }} {{ shopStore.state.order?.cart?.dest?.shipping?.dest?.delivery_time_range === 1 ? "Tag" : "Tage" }}
38
- </span>
39
- </div>
40
30
  <div class="viur-shop-cart-sidebar-info" v-if="shopStore.state.cartRoot.discount">
41
31
  <span v-html="$t('viur.shop.summary_discount')"></span>
42
32
  <sl-format-number lang="de" type="currency" currency="EUR" :value="state.discount">
@@ -58,12 +48,24 @@
58
48
  <sl-format-number lang="de" type="currency" currency="EUR" :value="vatObj.value">
59
49
  </sl-format-number>
60
50
  </div>
51
+ <div class="viur-shop-cart-sidebar-info viur-shop-cart-shipping-item" v-if="shopStore.state.order?.cart?.dest?.shipping">
52
+ <span v-html="$t('viur.shop.summary_delivery_time')"></span>
53
+ <span>
54
+ {{
55
+ shopStore.state.order?.cart?.dest?.shipping?.dest?.delivery_time_range ?
56
+ shopStore.state.order?.cart?.dest?.shipping?.dest?.delivery_time_range :
57
+ 0
58
+ }} {{ $t('viur.shop.day',state.shippingTime) }}
59
+ </span>
60
+ </div>
61
+
61
62
  <slot name="action-buttons" >
62
63
  <div class="viur-shop-cart-sidebar-btn-wrap" v-if="false && !shopStore.state.order?.['is_paid']">
63
64
  <sl-button variant="success" size="large">{{ $t("shop.summary_checkout") }}</sl-button>
64
65
  </div>
65
66
  </slot>
66
67
  </LoadingHandler>
68
+
67
69
  </template>
68
70
 
69
71
  <script setup>
@@ -102,6 +104,14 @@ const state = reactive({
102
104
 
103
105
  return total
104
106
  }),
107
+ shippingTime:computed(()=>{
108
+ try{
109
+ let times = shopStore.state.order?.cart?.dest?.shipping?.dest?.delivery_time_range.split(" - ").map(x=>parseInt(x))
110
+ return times[1] - times[0]
111
+ }catch(e){
112
+ return "-"
113
+ }
114
+ }),
105
115
  discount:computed(()=> (state.cartTotal - shopStore.state.cartRoot.total_discount_price)*-1),
106
116
  total: computed(() => {
107
117
  return shopStore.state.cartRoot.total
@@ -68,3 +68,10 @@ onBeforeMount(()=>{
68
68
  })
69
69
  })
70
70
  </script>
71
+
72
+ <style scoped>
73
+ sl-radio-group {
74
+ margin-bottom: var(--ignt-spacing-medium);
75
+ margin-top: var(--ignt-spacing-medium);
76
+ }
77
+ </style>
@@ -66,7 +66,7 @@ function updateShippingMethod(selection){
66
66
  }
67
67
 
68
68
  async function nextStep(){
69
- await fetchOrder(shopStore.state.orderKey)
69
+ return await fetchOrder(shopStore.state.orderKey)
70
70
  }
71
71
 
72
72
  onBeforeMount(()=>{
@@ -51,12 +51,14 @@ onMounted(()=>{
51
51
 
52
52
  <style scoped>
53
53
  sl-radio-group {
54
- margin-top: var(--ignt-spacing-small);
54
+ margin-bottom: var(--ignt-spacing-medium);
55
+ margin-top: var(--ignt-spacing-medium);
55
56
  }
56
57
 
57
58
  sl-card {
58
59
  width: calc(100% - 6px);
59
60
  margin-left: 3px;
61
+ margin-top: var(--ignt-spacing-small);
60
62
  &[selected]::part(base){
61
63
  border:1px solid var(--sl-color-primary-500);
62
64
  box-shadow: 0 0 0 var(--sl-focus-ring-width) var(--sl-input-focus-ring-color);
@@ -27,7 +27,7 @@
27
27
  :value="item.quantity"
28
28
  @sl-change="changeAmount($event.target.value)"
29
29
  >
30
- <dialog-Button slot="prefix" class="decent" v-if="item.quantity===1" variant="danger" outline>
30
+ <dialog-Button slot="prefix" class="decent" v-if="item.quantity===1" variant="danger" outline :disabled="!edit">
31
31
  <sl-icon name="trash"></sl-icon>
32
32
  <template #dialog="{close}">
33
33
  {{ $t('messages.remove_article_from_cart') }}
@@ -55,21 +55,25 @@
55
55
  </script>
56
56
 
57
57
  <style scoped>
58
- .payment-selection{
58
+ sl-details {
59
+ margin-top: var(--ignt-spacing-small);
60
+ }
61
+
62
+ .payment-selection {
59
63
  display: flex;
64
+ align-items: center;
65
+ flex-wrap: nowrap;
66
+ flex-direction: row;
67
+ align-content: center;
68
+ justify-content: space-between;
69
+ width: 100%;
70
+
71
+ .start {
72
+ display: flex;
60
73
  align-items: center;
61
74
  flex-wrap: nowrap;
62
- flex-direction: row;
63
- align-content: center;
64
- justify-content: space-between;
65
- width: 100%;
66
-
67
- .start{
68
- display: flex;
69
- align-items: center;
70
- flex-wrap: nowrap;
71
- gap:10px;
72
- }
75
+ gap:10px;
76
+ }
73
77
  }
74
78
 
75
79
  .simple::part(content){
@@ -122,16 +122,14 @@ function initUnzerForm(){
122
122
  function paymentError(error){
123
123
  state.loading = false
124
124
  state.hasError = true
125
- //reset session id
126
- //state.paymentHandler[shopStore.state.order?.['payment_provider']].jsessionId = state.paymentHandler[shopStore.state.order?.['payment_provider']].requestJSessionId()
127
125
  }
128
126
 
129
127
 
130
128
  function submitFormToUnzer(){
131
129
  PaymentCheckPause()
132
130
  state.loading = true
131
+ state.hasError = false
133
132
  let paymenttarget = shopStore.state.order?.['payment_provider'].split("-")[1]
134
- console.log(state.paymentHandler)
135
133
  //send to unzer
136
134
  state.paymentHandler[shopStore.state.order?.['payment_provider']].createResource().then((result)=>{
137
135
  Request.post(`${shopStore.state.shopUrl}/pp_unzer_${paymenttarget}/save_type`, {dataObj:{
@@ -11,7 +11,7 @@
11
11
  @change="optionChanged"
12
12
 
13
13
  >
14
-
14
+
15
15
  </payment-option>
16
16
 
17
17
  </sl-details-group>
@@ -51,5 +51,7 @@ function optionChanged(type){
51
51
  </script>
52
52
 
53
53
  <style scoped>
54
-
54
+ sl-radio-group {
55
+ margin-bottom: var(--ignt-spacing-small);
56
+ }
55
57
  </style>
@@ -4,7 +4,7 @@
4
4
  slot="nav"
5
5
  :panel="tab"
6
6
  :disabled="!shopStore.state.tabs[tab]['active']"
7
- @click="shopStore.navigateToTab(tab)"
7
+ @click="navigate"
8
8
  >
9
9
  <div class="viur-shop-order-step">
10
10
  <sl-icon
@@ -49,6 +49,12 @@ const props = defineProps({
49
49
  default:"-"
50
50
  }
51
51
  });
52
+
53
+ function navigate(){
54
+ if (!shopStore.state.tabs[props.tab]['active']) return false
55
+ shopStore.navigateToTab(props.tab)
56
+ }
57
+
52
58
  </script>
53
59
 
54
60
  <style scoped>
@@ -78,13 +78,13 @@ export const useAddress = defineStore("useAddressStore", () => {
78
78
  let key = state[`${type}Data`]['key']
79
79
  if (type === 'shipping'){
80
80
  const {updateCart} = useCart()
81
- updateCart({shipping_address_key:key})
81
+ await updateCart({shipping_address_key:key})
82
82
  }else if (type === 'billing'){
83
83
  const {addOrUpdateOrder} = useOrder()
84
84
  await addOrUpdateOrder({billing_address_key:key})
85
85
  if(billingIsShipping){
86
86
  const {updateCart} = useCart()
87
- updateCart({shipping_address_key:key})
87
+ await updateCart({shipping_address_key:key})
88
88
  }
89
89
  }
90
90
  }
@@ -61,8 +61,9 @@ export function useCart() {
61
61
  // fetch list of Rootnodes and saves the first one
62
62
 
63
63
  return Request.get(`${shopStore.state.shopUrl}/cart/listRootNodes`).then(async (resp)=>{
64
- let data = await resp.json()
64
+ let data = await resp.clone().json()
65
65
  shopStore.state.cartRoot = data.filter(i=>i['cart_type']==='basket')?.[0] ? data.filter(i=>i['cart_type']==='basket')[0]:[]
66
+ return resp
66
67
  })
67
68
  }
68
69
 
@@ -71,8 +72,9 @@ export function useCart() {
71
72
  return Request.get(`${shopStore.state.shopApiUrl}/cart_list`,{dataObj:{
72
73
  cart_key:key
73
74
  }}).then(async( resp) =>{
74
- let data = await resp.json()
75
+ let data = await resp.clone().json()
75
76
  shopStore.state.cartList=data
77
+ return resp
76
78
  })
77
79
  }
78
80
 
@@ -105,6 +107,7 @@ export function useCart() {
105
107
  dataObj: removeUndefinedValues(data)
106
108
  }).then(async (resp)=>{
107
109
  fetchCart()
110
+ return resp
108
111
  })
109
112
  }
110
113
 
@@ -20,14 +20,16 @@ export function useOrder() {
20
20
  }
21
21
  function fetchOrder(key){
22
22
  state.isLoading = true
23
+
23
24
  return Request.post(shopStore.state.shopApiUrl+"/order_view",{dataObj:{
24
25
  "order_key": key
25
26
  }}).then(async (resp)=>{
26
- let data = await resp.json()
27
+ let data = await resp.clone().json()
27
28
  updateOrderState(data['skel']['key'], data['skel'])
28
29
  shopStore.state.canCheckout = data["can_checkout"]
29
30
  shopStore.state.canOrder = data["can_order"]
30
31
  state.isLoading = false
32
+ return resp
31
33
  }).catch((error)=>{
32
34
  shopStore.state.order = null
33
35
  shopStore.state.orderKey = null
@@ -64,9 +66,10 @@ export function useOrder() {
64
66
  data["cart_key"] = shopStore.state.cartRoot['key']
65
67
  }
66
68
  return Request.post(url,{dataObj:removeUndefinedValues(data)}).then(async(resp)=>{
67
- let data = await resp.json()
69
+ let data = await resp.clone().json()
68
70
  updateOrderState(data['key'], data)
69
71
  state.isUpdating=false
72
+ return resp
70
73
  }).then(async ( resp)=>{
71
74
  fetchOrder(shopStore.state.orderKey)
72
75
  return resp
@@ -16,6 +16,7 @@ export const usePayment = defineStore("usePaymentStore", () => {
16
16
  }
17
17
 
18
18
  const simpleProviders = [
19
+ "invoice",
19
20
  'prepayment',
20
21
  'unzer-paypal',
21
22
  'unzer-sofort'
@@ -46,7 +47,7 @@ export const usePayment = defineStore("usePaymentStore", () => {
46
47
  currentOption.description = provider[1]['descr']
47
48
  currentOption.icon = iconMap[provider[0]]
48
49
  currentOption.widget = "simple"
49
- // if (simpleProviders.includes(provider[0])){
50
+ //if (simpleProviders.includes(provider[0])){
50
51
  // currentOption.widget = "simple" // payment provider musst be initialized later
51
52
  //}
52
53
 
@@ -72,4 +73,4 @@ export const usePayment = defineStore("usePaymentStore", () => {
72
73
  fetchPaymentData
73
74
 
74
75
  }
75
- })
76
+ })
package/src/shop.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { reactive, computed, watch, shallowRef } from "vue";
3
3
  import {ShopCart, ShopUserDataGuest, ShopShippingMethod, ShopPaymentProvider, ShopOrderComplete, ShopOrderConfirm} from './Steps/index'
4
4
  import { defineStore } from "pinia";
5
- import { useUrlSearchParams } from '@vueuse/core'
5
+ import { useUrlSearchParams,useTimeoutFn } from '@vueuse/core'
6
6
  import AddressFormLayout from './components/AddressFormLayout.vue';
7
7
 
8
8
  import { Request } from "@viur/vue-utils";
@@ -38,7 +38,7 @@ export const useViurShopStore = defineStore("viurshopStore", () => {
38
38
  params:{},
39
39
  displayName: "viur.shop.order_step_data", //Daten Eingeben
40
40
  icon: { name: "card-list" },
41
- active:computed(()=>!state.order?.['is_checkout_in_progress'] && !state.order?.['is_ordered'] && state.cartList.length>0), //active if checkout not startet and cart is not empty
41
+ active:computed(()=>state.order && !state.order?.['is_checkout_in_progress'] && !state.order?.['is_ordered'] && state.cartList.length>0), //active if checkout not startet and cart is not empty
42
42
  validating:false,
43
43
  valid:false
44
44
  },
@@ -56,7 +56,7 @@ export const useViurShopStore = defineStore("viurshopStore", () => {
56
56
  params:{},
57
57
  displayName: "viur.shop.order_step_payment", //Zahlungsart auswählen
58
58
  icon: { name: "credit-card" },
59
- active:computed(()=>!state.order?.['is_checkout_in_progress'] && state.order && state.cartRoot?.['shipping']), // we need a active order
59
+ active:computed(()=>!state.order?.['is_checkout_in_progress'] && state.order && state.cartRoot?.['shipping'] && state.cartRoot?.['shipping_address']), // we need a active order
60
60
  validating:false,
61
61
  valid:false
62
62
  },
@@ -199,7 +199,7 @@ export const useViurShopStore = defineStore("viurshopStore", () => {
199
199
  Request.post(`${state.shopUrl}/order/checkout_start`,{dataObj:{
200
200
  order_key:state.orderKey
201
201
  }}).then(async (resp)=>{
202
- let data = await resp.json()
202
+ let data = await resp.clone().json()
203
203
  state.paymentProviderData = data['payment']
204
204
 
205
205
  if (!data['payment']){
@@ -212,6 +212,7 @@ export const useViurShopStore = defineStore("viurshopStore", () => {
212
212
  }else{
213
213
  resolve()
214
214
  }
215
+ return resp
215
216
  }).catch(error=>{
216
217
  reject(error)
217
218
  })
@@ -224,28 +225,53 @@ export const useViurShopStore = defineStore("viurshopStore", () => {
224
225
  Request.post(`${state.shopUrl}/order/checkout_order`,{dataObj:{
225
226
  order_key:state.orderKey
226
227
  }}).then(async (resp)=>{
227
- let data = await resp.json()
228
+ let data = await resp.clone().json()
228
229
  if (!resp.ok){
229
230
  reject(data)
230
231
  } else {
231
- state.order = data['skel']
232
- state.paymentProviderData = data['payment']
232
+ state.order = data['skel']
233
+ state.paymentProviderData = data['payment']
233
234
 
234
- if(state.order?.['is_ordered']){
235
- // order is finished
235
+ if(state.order?.['is_ordered']){
236
+ // order is finished
237
+ useTimeoutFn(() => {
236
238
  navigateToTab('complete')
237
- }
238
- resolve(data)
239
- }
240
-
239
+ }, 300)
241
240
 
241
+ }
242
+ resolve(data)
243
+ }
244
+ return resp
242
245
  }).catch(error=>{
243
246
  reject(error)
244
247
  })
245
248
  })
246
249
  }
247
250
 
251
+ function tabValidation(nextfunction, navigatefunction){
252
+ state.tabs[state.currentTab]['valid']=false
253
+ state.tabs[state.currentTab]['validating']=true
254
+
255
+ //validate step, like send forms or something like this
256
+ Promise.resolve(nextfunction()).then((resp)=>{
248
257
 
258
+ if (resp){
259
+ state.tabs[state.currentTab]['valid']=true
260
+ state.tabs[state.currentTab]['validating']=false
261
+ useTimeoutFn(() => {
262
+ navigatefunction()
263
+ }, 300)
264
+
265
+ }else{
266
+ state.tabs[state.currentTab]['valid']=false
267
+ state.tabs[state.currentTab]['validating']=false
268
+ }
269
+ }).catch(error=>{
270
+ console.log(error)
271
+ state.tabs[state.currentTab]['valid']=false
272
+ state.tabs[state.currentTab]['validating']=false
273
+ })
274
+ }
249
275
 
250
276
 
251
277
  return {
@@ -253,6 +279,7 @@ export const useViurShopStore = defineStore("viurshopStore", () => {
253
279
  navigateToTab,
254
280
  navigateToNext,
255
281
  navigateToPrevious,
282
+ tabValidation,
256
283
  fetchMetaData,
257
284
  checkout,
258
285
  checkoutOrder,
@@ -15,7 +15,7 @@ export default {
15
15
  'order_ready_to_ship': 'Ihre Bestellung ist fertig für den Versand.',
16
16
  'cart_empty': 'Es befinden sich noch keine Artikel im Warenkorb.',
17
17
  'order_summary': 'Bestellzusammenfassung',
18
- 'deliverytime': 'Lieferzeit',
18
+ 'deliverytime': 'Voraussichtliche Lieferzeit',
19
19
  'day': 'Tag | Tage',
20
20
  'availability': 'Verfügbarkeit',
21
21
  'quantity': 'Anzahl',
@@ -25,6 +25,7 @@ export default {
25
25
  'payment': 'Zahlung',
26
26
  'pay': 'Bezahlen',
27
27
  'next': 'weiter',
28
+ 'edit': 'bearbeiten',
28
29
  'add_discount': 'Hinzufügen',
29
30
  'add_discount_placeholder': 'Dein Rabattcode',
30
31
  'use_shipping_as_billing_address': 'Lieferung zur Rechnungsadresse',
@@ -25,6 +25,7 @@ export default {
25
25
  'payment': 'Payment',
26
26
  'pay': 'Pay',
27
27
  'next': 'next',
28
+ 'edit': 'edit',
28
29
  'add_discount': 'Add',
29
30
  'add_discount_placeholder': 'Your discount code',
30
31
  'use_shipping_as_billing_address': 'Use shipping address as billing address',
@@ -25,6 +25,7 @@ export default {
25
25
  'payment': 'Paiement',
26
26
  'pay': 'Payer',
27
27
  'next': 'continuer',
28
+ 'edit': 'éditer',
28
29
  'add_discount': 'Valider',
29
30
  'add_discount_placeholder': 'Votre code promo',
30
31
  'use_shipping_as_billing_address': 'Livraison à l\'adresse de facturation',
@@ -39,7 +40,7 @@ export default {
39
40
  'summary_discount': 'Vous économisez sur votre achat',
40
41
  'summary_checkout': 'Acheter cet article',
41
42
  'summary_total': 'Montant total',
42
- 'summary_vat': 'TVA incluse ({vat_percentage})',
43
+ 'summary_vat': 'TVA incluse ({percentage})',
43
44
  'discount_not_found': 'Ce code promo n’existe pas.',
44
45
  'discount_not_active': 'Ce code promo n’est pas actif.',
45
46
  'discount_not_available': 'Ce code promo n’est pas valable pour ce pays.',