@wikala/spmkt 2.31.1 → 3.0.0-beta.1

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 (132) hide show
  1. package/MIGRATION_GUIDE.md +310 -0
  2. package/api/product.js +1 -0
  3. package/api/request.js +12 -6
  4. package/api/user.js +1 -1
  5. package/components/Account/AccountDashboard.vue +101 -101
  6. package/components/Account/AccountStore.js +57 -31
  7. package/components/Account/AffiliateReport.vue +56 -60
  8. package/components/Account/{OrderDetail.vue → Orders/OrderDetail.vue} +44 -30
  9. package/components/Account/Orders/Orders.vue +124 -0
  10. package/components/Account/{AccountSettings.vue → Settings/AccountSettings.vue} +4 -4
  11. package/components/Account/Settings/ChangeEmail.vue +136 -0
  12. package/components/Account/Settings/ChangeName.vue +82 -0
  13. package/components/Account/Settings/ChangePassword.vue +91 -0
  14. package/components/Address/Address.vue +38 -57
  15. package/components/Address/AddressBook.vue +77 -57
  16. package/components/Address/AddressSelect.vue +94 -87
  17. package/components/Address/Edit.vue +253 -265
  18. package/components/Address/PostalCode.vue +22 -21
  19. package/components/AgeGate.vue +11 -5
  20. package/components/Auth/Login.vue +62 -44
  21. package/components/Auth/Register.vue +82 -60
  22. package/components/Auth/ResetPassword.vue +45 -30
  23. package/components/Cart/AgeVerification/AgeChecker.vue +3 -3
  24. package/components/Cart/CartBadge.vue +15 -4
  25. package/components/Cart/CartBox.vue +19 -11
  26. package/components/Cart/CartItem.vue +3 -3
  27. package/components/Cart/CartMode.vue +6 -5
  28. package/components/Cart/CartPreview.vue +24 -18
  29. package/components/Cart/CreditCard/Everyware.vue +10 -10
  30. package/components/Cart/CreditCard/ExtendedCreditCard.vue +5 -5
  31. package/components/Cart/CreditCard/SquarePay.vue +18 -16
  32. package/components/Cart/CreditCard/StandardCreditCard.vue +9 -9
  33. package/components/Cart/Delivery/Delivery.vue +16 -12
  34. package/components/Cart/Delivery/DeliveryAddress.vue +1 -1
  35. package/components/Cart/Delivery/DeliveryMethods.vue +1 -1
  36. package/components/Cart/Delivery/DeliveryOptions.vue +15 -9
  37. package/components/Cart/Delivery/DeliveryTypes.vue +8 -5
  38. package/components/Cart/Delivery/ReservationSlots.vue +14 -8
  39. package/components/Cart/Disclaimer.vue +1 -1
  40. package/components/Cart/OrderConfirmation.vue +1 -1
  41. package/components/Cart/Payment/Payment.vue +37 -33
  42. package/components/Cart/Payment/PaymentMethods.vue +6 -4
  43. package/components/Cart/ReviewAndSubmit.vue +9 -7
  44. package/components/Cart/ShoppingCart.vue +42 -31
  45. package/components/Cart/Store/actions.js +1 -1
  46. package/components/Cart/Store/getters.js +2 -1
  47. package/components/Cart/Store/index.js +1 -1
  48. package/components/Cart/Store/mutations.js +9 -7
  49. package/components/Cart/Store/state.js +2 -2
  50. package/components/Cart/UserIdentity.vue +1 -1
  51. package/components/Category/CategoryFilter.vue +128 -114
  52. package/components/Category/CategorySort.vue +44 -32
  53. package/components/Category/LoadMore.vue +39 -23
  54. package/components/DeliverTo.vue +10 -15
  55. package/components/DeliveryNotice.vue +72 -68
  56. package/components/DobInput.vue +24 -24
  57. package/components/Gmaps/GmapsAutocomplete.vue +139 -78
  58. package/components/Gmaps/GmapsLocations.vue +1 -1
  59. package/components/Gmaps/GmapsSingleLocation.vue +121 -87
  60. package/components/MobileMenu/icons/LeftArrowIcon.vue +1 -1
  61. package/components/MobileMenu/icons/MenuIcon.vue +1 -1
  62. package/components/MobileMenu/icons/RightArrowIcon.vue +1 -1
  63. package/components/ModalContainer/ModalContainer.vue +20 -13
  64. package/components/ModalContainer/index.js +62 -18
  65. package/components/Product/AddToCart.vue +237 -221
  66. package/components/Product/BoxAddToCart.vue +114 -86
  67. package/components/Product/Compare.vue +91 -49
  68. package/components/Product/CompareBox.vue +128 -123
  69. package/components/Product/Lookup.vue +92 -65
  70. package/components/Product/Photo.vue +105 -66
  71. package/components/Product/Price.vue +64 -43
  72. package/components/Product/ProductAutocomplete.vue +52 -57
  73. package/components/Product/ProductBox.vue +61 -38
  74. package/components/Product/ProductImages.vue +83 -86
  75. package/components/Product/Quantity.vue +115 -53
  76. package/components/Product/QuickView.vue +52 -45
  77. package/components/Product/RelatedProducts.vue +88 -23
  78. package/components/Product/SKU.vue +27 -8
  79. package/components/Product/Variants.vue +336 -342
  80. package/components/Product/reviews-questions/ProductQuestions.vue +226 -198
  81. package/components/Product/reviews-questions/ProductReviews.vue +122 -107
  82. package/components/Product/reviews-questions/Review.vue +54 -59
  83. package/components/Product/reviews-questions/ReviewForm.vue +222 -170
  84. package/components/Product/reviews-questions/ReviewImages.vue +197 -216
  85. package/components/Product/reviews-questions/Vote.vue +83 -57
  86. package/components/QuantityInput.vue +18 -8
  87. package/components/RangeInput.vue +15 -8
  88. package/components/Recaptcha.vue +8 -1
  89. package/components/SelectShippingCountry.vue +81 -62
  90. package/components/TimedOffer.vue +59 -74
  91. package/composables/globals.js +53 -0
  92. package/config.js +5 -2
  93. package/index.js +41 -10
  94. package/install.js +88 -0
  95. package/locales/en.json +2 -1
  96. package/locales/sr.json +2 -1
  97. package/package.json +49 -37
  98. package/utils/animate.css +50 -0
  99. package/utils/animate.js +1 -1
  100. package/utils/buefy.js +62 -0
  101. package/utils/directives.js +28 -45
  102. package/utils/event-bus.js +56 -0
  103. package/utils/filters.js +24 -7
  104. package/utils/format-date.js +17 -0
  105. package/utils/{gmaps.js → google/gmaps.js} +43 -10
  106. package/utils/{google-analytics-eec.js → google/google-analytics-eec.js} +7 -7
  107. package/utils/random-id.js +10 -0
  108. package/babel.config.js +0 -5
  109. package/components/Account/ChangeEmail.vue +0 -133
  110. package/components/Account/ChangeName.vue +0 -92
  111. package/components/Account/ChangePassword.vue +0 -94
  112. package/components/Account/CreditCards.vue +0 -18
  113. package/components/Account/Orders.vue +0 -110
  114. package/components/Account/Settings.vue +0 -18
  115. package/components/Cart/Delivery/DeliveryAddressGuest.spec.js +0 -128
  116. package/components/Cart/Delivery/DeliveryTypes.spec.js +0 -83
  117. package/components/Cart/PCIBadge/SecurityMetrics.vue +0 -11
  118. package/components/Instagram.vue +0 -49
  119. package/components/ProductImageModal.vue +0 -41
  120. package/jest.config.js +0 -16
  121. package/test/e2e/.babelrc.js +0 -8
  122. package/test/e2e/.eslintrc.js +0 -11
  123. package/test/e2e/accAuth.spec.js +0 -64
  124. package/test/e2e/ageGate.spec.js +0 -26
  125. package/test/e2e/checkout.spec.js +0 -106
  126. package/test/e2e/compare.spec.js +0 -52
  127. package/test/e2e/config/data.js +0 -21
  128. package/test/e2e/config/routes.js +0 -11
  129. package/test/e2e/region.spec.js +0 -46
  130. package/test/e2e/search.spec.js +0 -32
  131. package/tests/vueBuefy.js +0 -4
  132. package/tsconfig.json +0 -8
@@ -5,11 +5,12 @@
5
5
  </template>
6
6
 
7
7
  <script>
8
+ import { ref, onMounted } from 'vue'
9
+ import { useBuefy, useT } from '../../composables/globals'
8
10
  import config from '../../config'
9
- import _ from 'underscore'
10
- import GoogleAnalyticsEEC from '../../utils/google-analytics-eec.js'
11
-
11
+ import GoogleAnalyticsEEC from '../../utils/google/google-analytics-eec.js'
12
12
  import { request, Cart } from '../../api'
13
+ import { eventBus } from '../../utils/event-bus'
13
14
 
14
15
  export default {
15
16
  name: 'BoxAddToCart',
@@ -21,129 +22,156 @@ export default {
21
22
  },
22
23
  },
23
24
 
24
- data() {
25
- return {
26
- loading: false,
27
- product: {},
28
- qty: 1,
29
- }
30
- },
31
-
32
- methods: {
33
- eecProduct() {
34
- let eecProduct = {
35
- item_id: this.product.id,
36
- item_name: this.product.name,
37
- price: this.product.price,
38
- item_brand: this.product.brand ? this.product.brand.name : '',
39
- item_category: this.product?.category?.path.startsWith('/') ? this.product?.category?.path.substr(1) : this.product?.category?.path,
40
- quantity: parseInt(this.qty, 10)
25
+ emits: ['success'],
26
+
27
+ setup(props, { emit }) {
28
+ const $buefy = useBuefy()
29
+ const { t: $t } = useT()
30
+
31
+ // Reactive state
32
+ const loading = ref(false)
33
+ const product = ref({})
34
+ const qty = ref(1)
35
+ const product_id = ref(props.productId)
36
+
37
+ // Methods
38
+ const eecProduct = () => {
39
+ const eecProduct = {
40
+ item_id: product.value.id,
41
+ item_name: product.value.name,
42
+ price: product.value.price,
43
+ item_brand: product.value.brand ? product.value.brand.name : '',
44
+ item_category: product.value?.category?.path.startsWith('/')
45
+ ? product.value?.category?.path.substr(1)
46
+ : product.value?.category?.path,
47
+ quantity: parseInt(qty.value, 10)
41
48
  }
42
- //console.log('eecProduct ', eecProduct)
43
49
  return eecProduct
44
- },
50
+ }
45
51
 
46
- productDetails() {
47
- let product = this.eecProduct()
48
- product.image_url = this.product.images && this.product.images[0] ? this.product.images[0].url : ''
49
- return product
50
- },
52
+ const productDetails = () => {
53
+ const prod = eecProduct()
54
+ prod.image_url = product.value.images && product.value.images[0]
55
+ ? product.value.images[0].url
56
+ : ''
57
+ return prod
58
+ }
51
59
 
52
- variantsInStock() {
53
- let vis = this.product.variants.filter(variant => {
60
+ const variantsInStock = () => {
61
+ const vis = product.value.variants?.filter(variant => {
54
62
  return variant.in_stock
55
- })
63
+ }) || []
56
64
  return vis.length
57
- },
65
+ }
58
66
 
59
- async updateCart() {
67
+ const updateCart = async () => {
60
68
  try {
61
- let response = await Cart.update({
62
- mode: this.mode,
63
- id: this.product.id,
64
- qty: this.qty
69
+ const response = await Cart.update({
70
+ mode: 'add',
71
+ id: product.value.id,
72
+ qty: qty.value
65
73
  })
66
- //console.log(response.data)
74
+
67
75
  if (response.data) {
68
- this.$bus.$emit('updateCart', response.data)
76
+ eventBus.emit('updateCart', response.data)
69
77
  } else {
70
- throw new Error(this.$t('cart.updateCartErrorUnknown'))
78
+ throw new Error($t('cart.updateCartErrorUnknown'))
71
79
  }
72
80
  return response.data
73
81
  } catch (error) {
74
82
  if (!error.message) {
75
- error.message = this.$t('cart.updateCartError', error.status)
83
+ error.message = $t('cart.updateCartError', error.status)
76
84
  }
77
- this.$buefy.dialog.alert({
78
- title: this.$t('global.error'),
85
+ $buefy.dialog.alert({
86
+ title: $t('global.error'),
79
87
  message: error.message,
80
88
  confirmText: 'OK'
81
89
  })
82
90
  } finally {
83
- this.loading = false
91
+ loading.value = false
84
92
  }
85
- },
93
+ }
86
94
 
87
- async addToCart(event) {
88
- this.loading = true
89
- let cartResponse = await this.updateCart()
95
+ const addToCart = async () => {
96
+ loading.value = true
97
+ const cartResponse = await updateCart()
90
98
  if (cartResponse) {
91
- this.$emit('success')
92
- this.$bus.$emit('addToCart', this.productDetails(), this.el$)
99
+ emit('success')
100
+ eventBus.emit('addToCart', productDetails())
93
101
  if (!!window.google_tag_manager) {
94
- GoogleAnalyticsEEC.addToCart(this.eecProduct(), () => {
95
- this.loadingAddToCart = false
102
+ GoogleAnalyticsEEC.addToCart(eecProduct(), () => {
103
+ loading.value = false
96
104
  })
97
105
  }
98
106
  }
99
- },
107
+ }
100
108
 
101
- async setProduct() {
102
- this.product = {};
103
- let resp = await request({
109
+ const setProduct = async () => {
110
+ product.value = {}
111
+ try {
112
+ const resp = await request({
113
+ // The storefront's products/{id} route; the API one is admin-only
104
114
  baseURL: config.BASE_URL,
105
- url: '/products/' + this.product_id
115
+ url: '/products/' + product_id.value
106
116
  })
107
- this.product = resp.data.product_resource
108
- },
117
+ product.value = resp.data.product_resource || {}
118
+ } catch (e) {
119
+ // The request helper rejects on HTTP errors and timeouts. Leave the product empty
120
+ // so handleClick's product id check stops instead of throwing
121
+ console.error('Cannot get product', e)
122
+ }
123
+ }
109
124
 
110
- async handleClick(e) {
111
- let btn = e.target
112
- btn.classList.add('is-loading')
113
-
114
- await this.setProduct()
125
+ const handleClick = async (e) => {
126
+ const btn = e.target
127
+ btn.classList.add('is-loading')
115
128
 
116
- if (!this.product.id) {
117
- return
118
- }
119
-
120
- if(this.variantsInStock() === 1) {
121
- this.product_id = this.product.variants.find(variant => variant.in_stock).id
122
- await this.setProduct();
129
+ try {
130
+ await setProduct()
131
+
132
+ if (!product.value.id) {
133
+ return
123
134
  }
124
135
 
125
- if(this.variantsInStock() > 1) {
126
- this.$buefy.dialog.confirm({
127
- title: 'Proizvod sa varijantama',
128
- message: 'Otvorićemo stranicu proizvoda da biste odabrali varijantu.',
129
- confirmText: 'Ok',
130
- type: 'is-success',
131
- onConfirm: () => {
132
- window.location.href = '/'+this.product.slug;
133
- }
134
- })
135
- btn.classList.remove('is-loading')
136
+ if (variantsInStock() === 1) {
137
+ product_id.value = product.value.variants.find(variant => variant.in_stock).id
138
+ await setProduct()
139
+ if (!product.value.id) {
136
140
  return
141
+ }
142
+ }
143
+
144
+ if (variantsInStock() > 1) {
145
+ $buefy.dialog.confirm({
146
+ title: 'Proizvod sa varijantama',
147
+ message: 'Otvorićemo stranicu proizvoda da biste odabrali varijantu.',
148
+ confirmText: 'Ok',
149
+ type: 'is-success',
150
+ ariaRole: 'alertdialog',
151
+ ariaModal: true,
152
+ onConfirm: () => {
153
+ window.location.href = '/' + product.value.slug
154
+ }
155
+ })
156
+ return
137
157
  }
138
158
 
139
- this.addToCart()
159
+ await addToCart()
160
+ } finally {
140
161
  btn.classList.remove('is-loading')
141
- },
162
+ }
163
+ }
142
164
 
143
- },
165
+ onMounted(() => {
166
+ product_id.value = props.productId
167
+ })
144
168
 
145
- mounted() {
146
- this.product_id = this.productId;
169
+ return {
170
+ loading,
171
+ product,
172
+ qty,
173
+ handleClick
174
+ }
147
175
  }
148
176
  }
149
177
  </script>
@@ -19,7 +19,7 @@
19
19
  <tr v-for="(attributes, i) in itemGeneral" :key="i">
20
20
  <td>{{ attributes[0].name }}</td>
21
21
  <td v-for="(attrs, i) in attributes" :key="i">
22
- <div v-if="attrs.options">{{ attrs.options | string }}</div>
22
+ <div v-if="attrs.options">{{ stringFilter(attrs.options) }}</div>
23
23
  <p v-else>{{ attrs.value }}</p>
24
24
  </td>
25
25
  </tr>
@@ -29,7 +29,7 @@
29
29
  <tr v-for="(attributes, i) in itemHeating" :key="i">
30
30
  <td>{{ attributes[0].name }}</td>
31
31
  <td v-for="(attrs, i) in attributes" :key="i">
32
- <div v-if="attrs.options">{{ attrs.options | string }}</div>
32
+ <div v-if="attrs.options">{{ stringFilter(attrs.options) }}</div>
33
33
  <p v-else>{{ attrs.value }}</p>
34
34
  </td>
35
35
  </tr>
@@ -55,54 +55,96 @@
55
55
  </div>
56
56
  </template>
57
57
 
58
- <script>
59
- import Lookup from '../../components/Product/Lookup'
60
- import scrollMonitor from 'scrollmonitor'
61
-
62
- export default {
63
- name: 'ComparePage',
64
- components: { Lookup },
65
- data() {
66
- return {
67
- items: [],
68
- itemGeneral: {},
69
- itemHeating: {},
70
- itemBattery: {},
71
- itemDimensions: {}
72
- }
73
- },
74
- filters: {
75
- string(value) {
76
- if (!value) return ''
77
- value = value.toString()
78
- return value
58
+ <script setup>
59
+ import { ref, onMounted, onUnmounted, getCurrentInstance } from 'vue'
60
+ import Lookup from './Lookup.vue'
61
+
62
+ defineOptions({ name: 'ComparePage' })
63
+
64
+ const props = defineProps({
65
+ compareData: {
66
+ type: Object,
67
+ default: () => ({
68
+ product: [],
69
+ General: {},
70
+ Heating: {},
71
+ Dimensions: {},
72
+ Battery: {}
73
+ })
74
+ }
75
+ })
76
+
77
+ // Get global properties
78
+ const instance = getCurrentInstance()
79
+
80
+ // Reactive state
81
+ const items = ref([])
82
+ const itemGeneral = ref({})
83
+ const itemHeating = ref({})
84
+ const itemBattery = ref({})
85
+ const itemDimensions = ref({})
86
+
87
+ // Methods
88
+ const stringFilter = (value) => {
89
+ if (!value) return ''
90
+ value = value.toString()
91
+ return value
92
+ }
93
+
94
+ let onScroll = null
95
+
96
+ // Adds .scrolled to the product name headers while the first one is out of view. Its
97
+ // position is read once, since .scrolled makes the headers fixed, which moves them.
98
+ const initScrollMonitor = () => {
99
+ const elToWatch = document.querySelectorAll('.fixedContent')
100
+ if (!elToWatch.length) return
101
+
102
+ const rect = elToWatch[0].getBoundingClientRect()
103
+ const top = rect.top + window.scrollY
104
+ const bottom = rect.bottom + window.scrollY
105
+ const isInViewport = () => top < window.scrollY + window.innerHeight && bottom > window.scrollY
106
+ const setScrolled = (scrolled) => elToWatch.forEach((el) => el.classList.toggle('scrolled', scrolled))
107
+
108
+ let inViewport = isInViewport()
109
+ if (!inViewport && top < window.scrollY) {
110
+ setScrolled(true)
111
+ }
112
+
113
+ onScroll = () => {
114
+ if (isInViewport() !== inViewport) {
115
+ inViewport = !inViewport
116
+ setScrolled(!inViewport)
79
117
  }
80
- },
81
- beforeMount() {
82
- this.items = window.compare.product
83
- this.itemGeneral = window.compare.General
84
- this.itemHeating = window.compare.Heating
85
- this.itemDimensions = window.compare.Dimensions
86
- this.itemBattery = window.compare.Battery
87
- },
88
- mounted() {
89
- window.addEventListener(
90
- 'load',
91
- () => {
92
- const elToWatch = document.querySelectorAll('.fixedContent')
93
-
94
- const watcher = scrollMonitor.create(elToWatch)
95
- watcher.lock()
96
-
97
- watcher.exitViewport(function () {
98
- elToWatch.forEach((el) => el.classList.add('scrolled'))
99
- })
100
- watcher.enterViewport(function () {
101
- elToWatch.forEach((el) => el.classList.remove('scrolled'))
102
- })
103
- },
104
- false
105
- )
106
118
  }
119
+ window.addEventListener('scroll', onScroll, { passive: true })
120
+ window.addEventListener('resize', onScroll, { passive: true })
107
121
  }
122
+
123
+ // Lifecycle hooks
124
+ onMounted(() => {
125
+ // Check if compareData prop is provided, otherwise use window.compare
126
+ if (props.compareData && props.compareData.product.length > 0) {
127
+ items.value = props.compareData.product
128
+ itemGeneral.value = props.compareData.General
129
+ itemHeating.value = props.compareData.Heating
130
+ itemDimensions.value = props.compareData.Dimensions
131
+ itemBattery.value = props.compareData.Battery
132
+ } else if (window.compare) {
133
+ items.value = window.compare.product
134
+ itemGeneral.value = window.compare.General
135
+ itemHeating.value = window.compare.Heating
136
+ itemDimensions.value = window.compare.Dimensions
137
+ itemBattery.value = window.compare.Battery
138
+ }
139
+
140
+ window.addEventListener('load', initScrollMonitor, false)
141
+ })
142
+
143
+ onUnmounted(() => {
144
+ window.removeEventListener('load', initScrollMonitor, false)
145
+ if (onScroll) {
146
+ window.removeEventListener('scroll', onScroll)
147
+ window.removeEventListener('resize', onScroll)
148
+ }
149
+ })
108
150
  </script>