@wikala/spmkt 2.31.1 → 3.0.0-beta.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.
Files changed (123) hide show
  1. package/MIGRATION_GUIDE.md +261 -0
  2. package/api/product.js +1 -0
  3. package/api/request.js +9 -4
  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 +7 -5
  49. package/components/Cart/UserIdentity.vue +1 -1
  50. package/components/Category/CategoryFilter.vue +128 -114
  51. package/components/Category/CategorySort.vue +44 -32
  52. package/components/Category/LoadMore.vue +39 -23
  53. package/components/DeliverTo.vue +10 -15
  54. package/components/DeliveryNotice.vue +72 -68
  55. package/components/DobInput.vue +23 -23
  56. package/components/Gmaps/GmapsAutocomplete.vue +139 -78
  57. package/components/Gmaps/GmapsLocations.vue +1 -1
  58. package/components/Gmaps/GmapsSingleLocation.vue +121 -87
  59. package/components/ModalContainer/ModalContainer.vue +12 -9
  60. package/components/ModalContainer/index.js +61 -18
  61. package/components/Product/AddToCart.vue +237 -221
  62. package/components/Product/BoxAddToCart.vue +114 -86
  63. package/components/Product/Compare.vue +68 -48
  64. package/components/Product/CompareBox.vue +128 -123
  65. package/components/Product/Lookup.vue +92 -65
  66. package/components/Product/Photo.vue +105 -66
  67. package/components/Product/Price.vue +64 -43
  68. package/components/Product/ProductAutocomplete.vue +52 -57
  69. package/components/Product/ProductBox.vue +61 -38
  70. package/components/Product/ProductImages.vue +83 -86
  71. package/components/Product/Quantity.vue +115 -53
  72. package/components/Product/QuickView.vue +52 -45
  73. package/components/Product/RelatedProducts.vue +88 -23
  74. package/components/Product/SKU.vue +27 -8
  75. package/components/Product/Variants.vue +335 -341
  76. package/components/Product/reviews-questions/ProductQuestions.vue +226 -198
  77. package/components/Product/reviews-questions/ProductReviews.vue +122 -107
  78. package/components/Product/reviews-questions/Review.vue +54 -59
  79. package/components/Product/reviews-questions/ReviewForm.vue +222 -170
  80. package/components/Product/reviews-questions/ReviewImages.vue +197 -216
  81. package/components/Product/reviews-questions/Vote.vue +83 -57
  82. package/components/QuantityInput.vue +18 -8
  83. package/components/RangeInput.vue +15 -8
  84. package/components/Recaptcha.vue +8 -1
  85. package/components/SelectShippingCountry.vue +81 -62
  86. package/components/TimedOffer.vue +59 -74
  87. package/composables/globals.js +53 -0
  88. package/config.js +5 -2
  89. package/index.js +41 -10
  90. package/install.js +75 -0
  91. package/locales/en.json +2 -1
  92. package/locales/sr.json +2 -1
  93. package/package.json +43 -30
  94. package/utils/directives.js +28 -45
  95. package/utils/event-bus.js +56 -0
  96. package/utils/filters.js +24 -7
  97. package/utils/{gmaps.js → google/gmaps.js} +43 -10
  98. package/utils/{google-analytics-eec.js → google/google-analytics-eec.js} +7 -7
  99. package/babel.config.js +0 -5
  100. package/components/Account/ChangeEmail.vue +0 -133
  101. package/components/Account/ChangeName.vue +0 -92
  102. package/components/Account/ChangePassword.vue +0 -94
  103. package/components/Account/CreditCards.vue +0 -18
  104. package/components/Account/Orders.vue +0 -110
  105. package/components/Account/Settings.vue +0 -18
  106. package/components/Cart/Delivery/DeliveryAddressGuest.spec.js +0 -128
  107. package/components/Cart/Delivery/DeliveryTypes.spec.js +0 -83
  108. package/components/Cart/PCIBadge/SecurityMetrics.vue +0 -11
  109. package/components/Instagram.vue +0 -49
  110. package/components/ProductImageModal.vue +0 -41
  111. package/jest.config.js +0 -16
  112. package/test/e2e/.babelrc.js +0 -8
  113. package/test/e2e/.eslintrc.js +0 -11
  114. package/test/e2e/accAuth.spec.js +0 -64
  115. package/test/e2e/ageGate.spec.js +0 -26
  116. package/test/e2e/checkout.spec.js +0 -106
  117. package/test/e2e/compare.spec.js +0 -52
  118. package/test/e2e/config/data.js +0 -21
  119. package/test/e2e/config/routes.js +0 -11
  120. package/test/e2e/region.spec.js +0 -46
  121. package/test/e2e/search.spec.js +0 -32
  122. package/tests/vueBuefy.js +0 -4
  123. package/tsconfig.json +0 -8
@@ -27,42 +27,44 @@
27
27
  <div class="columns">
28
28
  <div class="column">
29
29
  <b-field :label="$t('review.yourOpinion')" :type="{ 'is-danger': validationErrors.title }" :message="validationErrors.title">
30
- <b-input name="review_title" v-model="review.title" @input="validationErrors.title = ''" />
30
+ <b-input name="review_title" v-model="review.title" @update:model-value="validationErrors.title = ''" />
31
31
  </b-field>
32
32
  </div>
33
33
  </div>
34
34
  <div class="columns">
35
35
  <div class="column">
36
36
  <b-field :label="$t('review.yourReview')" :type="{ 'is-danger': validationErrors.body }" :message="validationErrors.body">
37
- <b-input name="review_text" v-model="review.body" @input="validationErrors.body = ''" type="textarea" />
37
+ <b-input name="review_text" v-model="review.body" @update:model-value="validationErrors.body = ''" type="textarea" />
38
38
  </b-field>
39
39
  </div>
40
40
  </div>
41
41
 
42
42
  <div v-if="imagePreviews.length" class="columns is-multiline is-mobile upload-preview-c">
43
- <div v-for="(img, i) in imagePreviews" v-if="img" :key="i" class="column is-3-desktop is-3-mobile upload-img-preview">
44
- <div v-if="img && img.uploading" class="image-placeholder" :style="{ backgroundImage: 'url(' + img.dataurl + ')' }">
45
- <div class="image-placeholder-uploading">
46
- <i class="fad fa-spinner-third fa-spin"></i>
43
+ <template v-for="(img, i) in imagePreviews" :key="i">
44
+ <div v-if="img" class="column is-3-desktop is-3-mobile upload-img-preview">
45
+ <div v-if="img.uploading" class="image-placeholder" :style="{ backgroundImage: 'url(' + img.dataurl + ')' }">
46
+ <div class="image-placeholder-uploading">
47
+ <i class="fad fa-spinner-third fa-spin"></i>
48
+ </div>
47
49
  </div>
48
- </div>
49
- <div v-else>
50
- <div class="upload-delete" @click="deleteImage(i, img.id)">
51
- <i class="far fa-times-circle"></i>
52
- </div>
53
- <img v-if="img.thumb_url" class="image-thumb" :src="img.thumb_url" />
54
- <div v-else class="image-placeholder" :style="{ backgroundImage: 'url(' + img.dataurl + ')' }">
55
- <div class="image-placeholder-error">{{ img.error }}</div>
50
+ <div v-else>
51
+ <div class="upload-delete" @click="deleteImage(i, img.id)">
52
+ <i class="far fa-times-circle"></i>
53
+ </div>
54
+ <img v-if="img.thumb_url" class="image-thumb" :src="img.thumb_url" />
55
+ <div v-else class="image-placeholder" :style="{ backgroundImage: 'url(' + img.dataurl + ')' }">
56
+ <div class="image-placeholder-error">{{ img.error }}</div>
57
+ </div>
58
+ <div v-if="img.title" class="image-title">{{ img.title }}</div>
56
59
  </div>
57
- <div v-if="img.title" class="image-title">{{ img.title }}</div>
58
60
  </div>
59
- </div>
61
+ </template>
60
62
  </div>
61
63
 
62
64
  <div class="columns is-multiline is-mobile upload-actions">
63
65
  <div class="column is-6 is-flex post-button-addp">
64
66
  <b-field class="file">
65
- <b-upload :multiple="true" :native="true" accept="image/*" @input="uploadReviewImages">
67
+ <b-upload :multiple="true" :native="true" accept="image/*" @update:model-value="uploadReviewImages">
66
68
  <a class="button is-info is-outlined">{{ $t('review.addPhotos') }}</a>
67
69
  </b-upload>
68
70
  </b-field>
@@ -78,184 +80,234 @@
78
80
  </div>
79
81
  </template>
80
82
 
81
- <script>
83
+ <script setup>
84
+ import { ref, onMounted, getCurrentInstance } from 'vue'
85
+ import { useBuefy, useT } from '../../../composables/globals'
82
86
  import { Product } from '../../../api'
83
87
 
84
- export default {
85
- name: 'ReviewForm',
86
-
87
- data() {
88
- return {
89
- postingReview: false,
90
- maxStars: 5,
91
- review: {
92
- title: '',
93
- recommended: '',
94
- images: [],
95
- body: '',
96
- rating: '',
97
- token: '',
98
- subject_id: '',
99
- subject_type: 'review',
100
- media_type: 'review-image'
101
- },
102
- imagePreviews: [],
103
- imageIndex: 0,
104
- validationErrors: {}
105
- }
88
+ const props = defineProps({
89
+ productId: {
90
+ type: Number,
91
+ default: null
92
+ },
93
+ initialToken: {
94
+ type: String,
95
+ default: ''
96
+ },
97
+ initialRating: {
98
+ type: Number,
99
+ default: 0
106
100
  },
101
+ onSuccess: {
102
+ type: Function,
103
+ default: null
104
+ }
105
+ })
107
106
 
108
- methods: {
109
- rate(rating) {
110
- this.validationErrors.rating = ''
111
- this.review.rating = rating
112
- },
107
+ const emit = defineEmits(['success', 'error', 'close'])
113
108
 
114
- scrollToReview() {
115
- let elReviewForm = document.getElementsByClassName('reviews-heading')[0]
116
- if (!elReviewForm) {
117
- return false
118
- } else elReviewForm.scrollIntoView({ block: 'center', behavior: 'smooth' })
119
- },
109
+ // Whether the parent (e.g. $modalContainer) listens for close; if not, the host's closeModal() closes the form
110
+ const instance = getCurrentInstance()
120
111
 
121
- async deleteImage(index, id) {
122
- this.imagePreviews.splice(index, 1)
123
- if (id) {
124
- this.review.images.splice(this.review.images.indexOf(id), 1)
125
- await Product.deleteImage(id)
126
- }
127
- },
112
+ const { t: $t } = useT()
113
+ const $buefy = useBuefy()
128
114
 
129
- async upload(image) {
130
- let imageData = new FormData()
131
- imageData.append('media-file', image)
132
- imageData.append('subject_type', 'review')
133
- imageData.append('media_type', 'review-image')
134
- if (this.review.token) {
135
- imageData.append('token', this.review.token)
136
- }
115
+ // Reactive state
116
+ const reviewForm = ref(null)
117
+ const postingReview = ref(false)
118
+ const maxStars = ref(5)
119
+ const review = ref({
120
+ title: '',
121
+ recommended: '',
122
+ images: [],
123
+ body: '',
124
+ rating: props.initialRating || '',
125
+ token: props.initialToken || '',
126
+ subject_id: '',
127
+ subject_type: 'review',
128
+ media_type: 'review-image'
129
+ })
130
+ const imagePreviews = ref([])
131
+ const imageIndex = ref(0)
132
+ const validationErrors = ref({})
137
133
 
138
- let config = { headers: { 'Content-Type': 'multipart/form-data' } }
134
+ // Methods
135
+ const rate = (rating) => {
136
+ validationErrors.value.rating = ''
137
+ review.value.rating = rating
138
+ }
139
139
 
140
- try {
141
- const response = await Product.postImages(imageData, config)
140
+ const scrollToReview = () => {
141
+ let elReviewForm = document.getElementsByClassName('reviews-heading')[0]
142
+ if (!elReviewForm) {
143
+ return false
144
+ } else {
145
+ elReviewForm.scrollIntoView({ block: 'center', behavior: 'smooth' })
146
+ }
147
+ }
142
148
 
143
- return {
144
- status: 1,
145
- data: response.data.data
146
- }
147
- } catch (err) {
148
- //this.validationErrors = err.errors
149
+ const deleteImage = async (index, id) => {
150
+ imagePreviews.value.splice(index, 1)
151
+ if (id) {
152
+ review.value.images.splice(review.value.images.indexOf(id), 1)
153
+ await Product.deleteImage(id)
154
+ }
155
+ }
149
156
 
150
- return {
151
- status: 0,
152
- data: err.errors
153
- }
154
- }
155
- },
157
+ const upload = async (image) => {
158
+ let imageData = new FormData()
159
+ imageData.append('media-file', image)
160
+ imageData.append('subject_type', 'review')
161
+ imageData.append('media_type', 'review-image')
162
+ if (review.value.token) {
163
+ imageData.append('token', review.value.token)
164
+ }
156
165
 
157
- async uploadReviewImages(imageList) {
158
- for (let i = 0; i < imageList.length; i++) {
159
- let imageFile = imageList[i]
160
- const fileReader = new FileReader()
161
- let imageDataURL = ''
162
- fileReader.readAsDataURL(imageFile)
163
- fileReader.addEventListener('load', (e) => {
164
- imageDataURL = event.target.result
165
- })
166
+ let config = { headers: { 'Content-Type': 'multipart/form-data' } }
166
167
 
167
- this.$set(this.imagePreviews, this.imageIndex, {
168
- uploading: true,
169
- dataurl: imageDataURL
170
- })
168
+ try {
169
+ const response = await Product.postImages(imageData, config)
171
170
 
172
- let uploadRes = await this.upload(imageList[i])
173
- if (uploadRes.status === 1) {
174
- this.review.images.push(uploadRes.data.id)
175
- this.$set(this.imagePreviews, this.imageIndex, {
176
- uploading: false,
177
- id: uploadRes.data.id,
178
- thumb_url: uploadRes.data.thumb_url,
179
- title: uploadRes.data.title
180
- })
181
- } else {
182
- this.$set(this.imagePreviews, this.imageIndex, {
183
- uploading: false,
184
- title: imageList[i].name,
185
- error: uploadRes.data && uploadRes.data['media-file'] ? uploadRes.data['media-file'] : this.$t('review.uploadError'),
186
- dataurl: imageDataURL
187
- })
188
- }
171
+ return {
172
+ status: 1,
173
+ data: response.data.data
174
+ }
175
+ } catch (err) {
176
+ return {
177
+ status: 0,
178
+ data: err.errors
179
+ }
180
+ }
181
+ }
182
+
183
+ const uploadReviewImages = async (imageList) => {
184
+ for (let i = 0; i < imageList.length; i++) {
185
+ let imageFile = imageList[i]
186
+ const fileReader = new FileReader()
187
+ let imageDataURL = ''
188
+ fileReader.readAsDataURL(imageFile)
189
+ fileReader.addEventListener('load', (e) => {
190
+ imageDataURL = e.target.result
191
+ })
192
+
193
+ imagePreviews.value[imageIndex.value] = {
194
+ uploading: true,
195
+ dataurl: imageDataURL
196
+ }
189
197
 
190
- this.imageIndex++
198
+ let uploadRes = await upload(imageList[i])
199
+ if (uploadRes.status === 1) {
200
+ review.value.images.push(uploadRes.data.id)
201
+ imagePreviews.value[imageIndex.value] = {
202
+ uploading: false,
203
+ id: uploadRes.data.id,
204
+ thumb_url: uploadRes.data.thumb_url,
205
+ title: uploadRes.data.title
191
206
  }
207
+ } else {
208
+ imagePreviews.value[imageIndex.value] = {
209
+ uploading: false,
210
+ title: imageList[i].name,
211
+ error: uploadRes.data && uploadRes.data['media-file'] ? uploadRes.data['media-file'] : $t('review.uploadError'),
212
+ dataurl: imageDataURL
213
+ }
214
+ }
192
215
 
193
- document.getElementById('reviews-form').scroll({
194
- top: 10000,
195
- left: 0,
196
- behavior: 'smooth'
197
- })
198
- },
216
+ imageIndex.value++
217
+ }
199
218
 
200
- async postReview() {
201
- this.id = window.wkl_product.id
202
- this.postingReview = true
203
- try {
204
- this.review.recommended = this.review.rating >= 3 ? 1 : 0
219
+ document.getElementById('reviews-form')?.scroll({
220
+ top: 10000,
221
+ left: 0,
222
+ behavior: 'smooth'
223
+ })
224
+ }
205
225
 
206
- let response = await Product.postReview(this.id, this.review)
226
+ const postReview = async () => {
227
+ const id = props.productId || window.wkl_product?.id
228
+ postingReview.value = true
229
+ try {
230
+ review.value.recommended = review.value.rating >= 3 ? 1 : 0
207
231
 
208
- if (response.status === 200 || response.status === 201) {
209
- this.$buefy.toast.open({
210
- duration: 5000,
211
- message: this.$t('review.thanks'),
212
- position: 'is-top',
213
- type: 'is-success'
214
- })
215
- this.$refs.reviewForm.reset()
216
- this.closeModal()
217
- setTimeout(() => {
218
- let urlReviewPosted = new URL(window.location.href).searchParams.get('review-posted')
219
- if (urlReviewPosted) {
220
- window.location.reload()
221
- } else {
222
- let url = new URL(window.location.href)
223
- let urlPostReview = url.searchParams.get('post-review')
224
- let urlToken = url.searchParams.get('token')
225
- if (urlPostReview || urlToken) {
226
- window.location.href = window.location.origin + window.location.pathname + '?review-posted=1'
227
- } else {
228
- window.location.href += '?review-posted=1'
229
- }
230
- }
231
- }, 1000)
232
- } else {
233
- this.$buefy.dialog.alert({
234
- title: this.$t('review.postReviewErrorTitle'),
235
- message: this.$t('review.postReviewError'),
236
- confirmText: 'OK'
237
- })
238
- }
239
- } catch (error) {
240
- this.validationErrors = error.errors
241
- if (error.errors.token) {
242
- error.message = this.$t('review.invalidToken')
243
- }
244
- this.$buefy.toast.open({
232
+ let response = await Product.postReview(id, review.value)
233
+
234
+ if (response.status === 200 || response.status === 201) {
235
+ if ($buefy) {
236
+ $buefy.toast.open({
245
237
  duration: 5000,
246
- message: error.message,
238
+ message: $t('review.thanks'),
247
239
  position: 'is-top',
248
- type: 'is-danger'
240
+ type: 'is-success'
249
241
  })
250
- } finally {
251
- this.postingReview = false
252
242
  }
253
- }
254
- },
243
+
244
+ reviewForm.value?.reset()
245
+
246
+ if (props.onSuccess) {
247
+ props.onSuccess(response.data)
248
+ }
249
+
250
+ emit('success', response.data)
251
+
252
+ // Close the modal the form was opened in, once: the container's close listener,
253
+ // or the host's closeModal() helper when the host opened it some other way
254
+ if (instance?.vnode.props?.onClose) {
255
+ emit('close')
256
+ } else if (instance?.proxy?.closeModal) {
257
+ instance.proxy.closeModal()
258
+ }
255
259
 
256
- mounted() {
257
- this.review.token = new URL(window.location.href).searchParams.get('token')
258
- this.review.rating = new URL(window.location.href).searchParams.get('rating')
260
+ setTimeout(() => {
261
+ let urlReviewPosted = new URL(window.location.href).searchParams.get('review-posted')
262
+ if (urlReviewPosted) {
263
+ window.location.reload()
264
+ } else {
265
+ let url = new URL(window.location.href)
266
+ let urlPostReview = url.searchParams.get('post-review')
267
+ let urlToken = url.searchParams.get('token')
268
+ if (urlPostReview || urlToken) {
269
+ window.location.href = window.location.origin + window.location.pathname + '?review-posted=1'
270
+ } else {
271
+ window.location.href += '?review-posted=1'
272
+ }
273
+ }
274
+ }, 1000)
275
+ } else {
276
+ if ($buefy) {
277
+ $buefy.dialog.alert({
278
+ title: $t('review.postReviewErrorTitle'),
279
+ message: $t('review.postReviewError'),
280
+ confirmText: 'OK'
281
+ })
282
+ }
283
+ emit('error', new Error($t('review.postReviewError')))
284
+ }
285
+ } catch (error) {
286
+ validationErrors.value = error.errors || {}
287
+ if (error.errors?.token) {
288
+ error.message = $t('review.invalidToken')
289
+ }
290
+ if ($buefy) {
291
+ $buefy.toast.open({
292
+ duration: 5000,
293
+ message: error.message,
294
+ position: 'is-top',
295
+ type: 'is-danger'
296
+ })
297
+ }
298
+ emit('error', error)
299
+ } finally {
300
+ postingReview.value = false
259
301
  }
260
302
  }
303
+
304
+ onMounted(() => {
305
+ if (!review.value.token) {
306
+ review.value.token = new URL(window.location.href).searchParams.get('token') || ''
307
+ }
308
+ if (!review.value.rating) {
309
+ const ratingParam = new URL(window.location.href).searchParams.get('rating')
310
+ review.value.rating = ratingParam ? parseInt(ratingParam) : ''
311
+ }
312
+ })
261
313
  </script>