@wikala/spmkt 2.31.0 → 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 (124) 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/Coupon.vue +4 -5
  30. package/components/Cart/CreditCard/Everyware.vue +10 -10
  31. package/components/Cart/CreditCard/ExtendedCreditCard.vue +5 -5
  32. package/components/Cart/CreditCard/SquarePay.vue +18 -16
  33. package/components/Cart/CreditCard/StandardCreditCard.vue +9 -9
  34. package/components/Cart/Delivery/Delivery.vue +16 -12
  35. package/components/Cart/Delivery/DeliveryAddress.vue +1 -1
  36. package/components/Cart/Delivery/DeliveryMethods.vue +1 -1
  37. package/components/Cart/Delivery/DeliveryOptions.vue +15 -9
  38. package/components/Cart/Delivery/DeliveryTypes.vue +8 -5
  39. package/components/Cart/Delivery/ReservationSlots.vue +14 -8
  40. package/components/Cart/Disclaimer.vue +1 -1
  41. package/components/Cart/OrderConfirmation.vue +1 -1
  42. package/components/Cart/Payment/Payment.vue +37 -33
  43. package/components/Cart/Payment/PaymentMethods.vue +6 -4
  44. package/components/Cart/ReviewAndSubmit.vue +9 -7
  45. package/components/Cart/ShoppingCart.vue +42 -31
  46. package/components/Cart/Store/actions.js +1 -1
  47. package/components/Cart/Store/getters.js +2 -1
  48. package/components/Cart/Store/index.js +1 -1
  49. package/components/Cart/Store/mutations.js +7 -5
  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 +23 -23
  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/ModalContainer/ModalContainer.vue +12 -9
  61. package/components/ModalContainer/index.js +61 -18
  62. package/components/Product/AddToCart.vue +237 -221
  63. package/components/Product/BoxAddToCart.vue +114 -86
  64. package/components/Product/Compare.vue +68 -48
  65. package/components/Product/CompareBox.vue +128 -123
  66. package/components/Product/Lookup.vue +92 -65
  67. package/components/Product/Photo.vue +105 -66
  68. package/components/Product/Price.vue +64 -43
  69. package/components/Product/ProductAutocomplete.vue +52 -57
  70. package/components/Product/ProductBox.vue +61 -38
  71. package/components/Product/ProductImages.vue +83 -86
  72. package/components/Product/Quantity.vue +115 -53
  73. package/components/Product/QuickView.vue +52 -45
  74. package/components/Product/RelatedProducts.vue +88 -23
  75. package/components/Product/SKU.vue +27 -8
  76. package/components/Product/Variants.vue +335 -341
  77. package/components/Product/reviews-questions/ProductQuestions.vue +226 -198
  78. package/components/Product/reviews-questions/ProductReviews.vue +122 -107
  79. package/components/Product/reviews-questions/Review.vue +54 -59
  80. package/components/Product/reviews-questions/ReviewForm.vue +222 -170
  81. package/components/Product/reviews-questions/ReviewImages.vue +197 -216
  82. package/components/Product/reviews-questions/Vote.vue +83 -57
  83. package/components/QuantityInput.vue +18 -8
  84. package/components/RangeInput.vue +15 -8
  85. package/components/Recaptcha.vue +8 -1
  86. package/components/SelectShippingCountry.vue +81 -62
  87. package/components/TimedOffer.vue +59 -74
  88. package/composables/globals.js +53 -0
  89. package/config.js +5 -2
  90. package/index.js +41 -10
  91. package/install.js +75 -0
  92. package/locales/en.json +2 -1
  93. package/locales/sr.json +2 -1
  94. package/package.json +43 -30
  95. package/utils/directives.js +28 -45
  96. package/utils/event-bus.js +56 -0
  97. package/utils/filters.js +24 -7
  98. package/utils/{gmaps.js → google/gmaps.js} +43 -10
  99. package/utils/{google-analytics-eec.js → google/google-analytics-eec.js} +7 -7
  100. package/babel.config.js +0 -5
  101. package/components/Account/ChangeEmail.vue +0 -133
  102. package/components/Account/ChangeName.vue +0 -92
  103. package/components/Account/ChangePassword.vue +0 -94
  104. package/components/Account/CreditCards.vue +0 -18
  105. package/components/Account/Orders.vue +0 -110
  106. package/components/Account/Settings.vue +0 -18
  107. package/components/Cart/Delivery/DeliveryAddressGuest.spec.js +0 -128
  108. package/components/Cart/Delivery/DeliveryTypes.spec.js +0 -83
  109. package/components/Cart/PCIBadge/SecurityMetrics.vue +0 -11
  110. package/components/Instagram.vue +0 -49
  111. package/components/ProductImageModal.vue +0 -41
  112. package/jest.config.js +0 -16
  113. package/test/e2e/.babelrc.js +0 -8
  114. package/test/e2e/.eslintrc.js +0 -11
  115. package/test/e2e/accAuth.spec.js +0 -64
  116. package/test/e2e/ageGate.spec.js +0 -26
  117. package/test/e2e/checkout.spec.js +0 -106
  118. package/test/e2e/compare.spec.js +0 -52
  119. package/test/e2e/config/data.js +0 -21
  120. package/test/e2e/config/routes.js +0 -11
  121. package/test/e2e/region.spec.js +0 -46
  122. package/test/e2e/search.spec.js +0 -32
  123. package/tests/vueBuefy.js +0 -4
  124. package/tsconfig.json +0 -8
@@ -1,65 +1,88 @@
1
1
  <template>
2
- <div :class="grid">
2
+ <div :class="[{[grid]: true}, 'product-box']">
3
3
  <div class="box">
4
- <a :href="product.slug.split('/').pop()" class="image">
5
- <img :src="product.thumb_url" />
4
+ <a :href="productSlug" class="image">
5
+ <img :src="product.thumb_url" :alt="product.name" />
6
6
  </a>
7
7
  <div class="desc-container">
8
- <a :href="product.slug.split('/').pop()" class="description">{{ product.name }}</a>
8
+ <a :href="productSlug" class="description">{{ product.name }}</a>
9
9
  </div>
10
10
  <div class="stars-reviews">
11
11
  <div class="rating">
12
- <template v-if="product.reviews_count">
13
- <a :href="product.slug + '/reviews'">
14
- <i v-for="sc in starRating(product.rating)" style="margin-right: 3px;" :class="['fas', 'fa-star', sc]"></i>
12
+ <template v-if="hasReviews">
13
+ <a :href="reviewsHref">
14
+ <i
15
+ v-for="(sc, index) in starRating(product.rating)"
16
+ :key="index"
17
+ style="margin-right: 3px;"
18
+ :class="['fas', 'fa-star', sc]"
19
+ ></i>
15
20
  </a>
16
- <a class="review-count" :href="product.slug + '/reviews'">{{product.reviews_count}}</a>
21
+ <a class="review-count" :href="reviewsHref">{{ product.reviews_count }}</a>
17
22
  </template>
18
23
  <template v-else>
19
- <i v-for="sc in starRating(product.rating)" :class="['fas', 'fa-star', sc]"></i>
24
+ <i
25
+ v-for="(sc, index) in starRating(product.rating)"
26
+ :key="index"
27
+ :class="['fas', 'fa-star', sc]"
28
+ ></i>
20
29
  </template>
21
30
  </div>
22
31
  </div>
23
32
  <div class="price-container">
24
- <p class="price">${{ product.price | formatMoney }}</p>
25
- <p v-if="product.price >= 50" class="free-delivery">FREE shipping</p>
33
+ <p class="price">${{ $filters.formatMoney(product.price) }}</p>
34
+ <p v-if="hasFreeShipping" class="free-delivery">FREE shipping</p>
26
35
  </div>
27
36
  </div>
28
37
  </div>
29
38
  </template>
30
39
 
31
- <script>
32
- export default {
33
- name: 'ProductBox',
40
+ <script setup>
41
+ import { computed, toRefs } from 'vue'
34
42
 
35
- props: {
36
- product: {
37
- type: Object,
38
- required: true
39
- },
40
- grid: String
41
- },
42
-
43
- computed: {
44
- getRating() {
45
- return (this.product.rating / 5) * 100
46
- }
43
+ const props = defineProps({
44
+ product: {
45
+ type: Object,
46
+ required: true
47
47
  },
48
+ grid: {
49
+ type: String,
50
+ default: ''
51
+ }
52
+ })
48
53
 
49
- methods: {
50
- starRating(rating) {
51
- let stars = Math.floor(rating)
52
- let halfStars = (rating - stars > .40) ? 1 : 0
53
- let other = 5 - stars - halfStars
54
- let s = ''
55
- s += 'fa-star star-on,'.repeat(stars)
56
- s += 'fa-star-half-alt star-on,'.repeat(halfStars)
57
- s += 'fa-star star-off,'.repeat(other)
54
+ const { product, grid } = toRefs(props)
58
55
 
59
- console.log('star rating ', s.substring(0, s.length-1), s.split(','))
56
+ const productSlug = computed(() => {
57
+ const slug = product.value?.slug || ''
58
+ const segments = slug.split('/').filter(Boolean)
59
+ return segments.length ? segments[segments.length - 1] : ''
60
+ })
60
61
 
61
- return s.substring(0, s.length-1).split(',')
62
- }
62
+ const reviewsHref = computed(() => {
63
+ if (!product.value?.slug) {
64
+ return ''
63
65
  }
66
+ return `${product.value.slug}/reviews`
67
+ })
68
+
69
+ const hasReviews = computed(() => Boolean(product.value?.reviews_count))
70
+
71
+ const hasFreeShipping = computed(() => {
72
+ const price = Number(product.value?.price)
73
+ return !Number.isNaN(price) && price >= 50
74
+ })
75
+
76
+ function starRating(rating = 0) {
77
+ const normalized = Math.max(0, Math.min(5, Number(rating) || 0))
78
+ const stars = Math.floor(normalized)
79
+ const halfStars = normalized - stars > 0.4 ? 1 : 0
80
+ const other = Math.max(0, 5 - stars - halfStars)
81
+ let s = ''
82
+ s += 'fa-star star-on,'.repeat(stars)
83
+ s += 'fa-star-half-alt star-on,'.repeat(halfStars)
84
+ s += 'fa-star star-off,'.repeat(other)
85
+
86
+ return s.substring(0, s.length - 1).split(',').filter(Boolean)
64
87
  }
65
88
  </script>
@@ -5,7 +5,7 @@
5
5
  v-model="activeImage"
6
6
  v-if="product.images.length > 0"
7
7
  :autoplay="false"
8
- :indicator="$mq === 'mobile'"
8
+ :indicator="mq === 'mobile'"
9
9
  :overlay="gallery"
10
10
  @click="switchGallery(true)"
11
11
  @change="changeImage"
@@ -15,14 +15,14 @@
15
15
  <b-carousel-item v-for="(image, i) in product.images" :key="i">
16
16
  <picture class="image">
17
17
  <img
18
- :src="image.url"
18
+ :src="image.url"
19
19
  :srcset="getSrcset(image)"
20
20
  decoding="async"
21
21
  sizes="(min-width: 1420px) 672px, (min-width: 1220px) 576px, (min-width: 1080px) 480px, (min-width: 780px) calc(40.71vw + 48px), 100vw">
22
22
  </picture>
23
23
  </b-carousel-item>
24
24
  <span v-if="gallery" @click="switchGallery(false)" class="modal-close is-large"></span>
25
- <template slot="list" slot-scope="props" v-if="product.images.length > 1">
25
+ <template v-slot:list="props" v-if="product.images.length > 1">
26
26
  <b-carousel-list
27
27
  v-model="props.active"
28
28
  v-bind="al"
@@ -43,98 +43,95 @@
43
43
  </div>
44
44
  </template>
45
45
 
46
- <script>
47
- import _ from 'underscore'
48
- import Photo from './Photo'
46
+ <script setup>
47
+ import { ref, reactive, watch, onMounted, onBeforeUnmount } from 'vue'
48
+ import { useMq } from '../../composables/globals'
49
+ import { eventBus } from '../../utils/event-bus'
49
50
 
50
- export default {
51
- name: 'ProductImages',
52
- components: { Photo },
53
- props: {
54
- product: {
55
- type: Object,
56
- default: function () {
57
- return {}
58
- }
59
- }
60
- },
51
+ defineOptions({ name: 'ProductImages' })
61
52
 
62
- data() {
63
- return {
64
- activeImage: 0,
65
- gallery: false,
66
- al: {
67
- hasGrayscale: true,
68
- itemsToShow: 4,
69
- breakpoints: {
70
- 768: {
71
- hasGrayscale: false,
72
- itemsToShow: 6
73
- },
74
- 960: {
75
- hasGrayscale: false,
76
- itemsToShow: 6
77
- }
78
- }
79
- }
80
- }
81
- },
53
+ const props = defineProps({
54
+ product: {
55
+ type: Object,
56
+ default: () => ({})
57
+ }
58
+ })
82
59
 
83
- watch: {
84
- gallery() {
85
- if (this.gallery) {
86
- console.log('setting items to show')
87
- this.al.breakpoints['960'].itemsToShow = 12
88
- } else {
89
- this.al.breakpoints['960'].itemsToShow = 6
90
- }
91
- }
92
- },
60
+ const emit = defineEmits(['update'])
93
61
 
94
- methods: {
95
- changeImage(e) {
96
- //console.log('changeImage ', e)
97
- },
62
+ const mq = useMq()
98
63
 
99
- getResizedImageUrl(original, resolution) {
100
- let lastDotPosition = original.lastIndexOf('.')
101
- original = original.replace('images', 'thumbs')
102
- return [original.slice(0, lastDotPosition), '-' + resolution, original.slice(lastDotPosition)].join('')
64
+ // Reactive state
65
+ const activeImage = ref(0)
66
+ const gallery = ref(false)
67
+ const al = reactive({
68
+ hasGrayscale: true,
69
+ itemsToShow: 4,
70
+ breakpoints: {
71
+ 768: {
72
+ hasGrayscale: false,
73
+ itemsToShow: 6
103
74
  },
75
+ 960: {
76
+ hasGrayscale: false,
77
+ itemsToShow: 6
78
+ }
79
+ }
80
+ })
104
81
 
105
- getSrcset(imgdata) {
106
- if(!imgdata.available_sizes) return
107
- let srcset = []
108
- imgdata.available_sizes.forEach(asize => {
109
- srcset.push(`${asize.url} ${asize.width}w`)
110
- })
111
- return srcset.join(', ')
112
- },
82
+ // Watchers
83
+ watch(gallery, (newVal) => {
84
+ if (newVal) {
85
+ console.log('setting items to show')
86
+ al.breakpoints['960'].itemsToShow = 12
87
+ } else {
88
+ al.breakpoints['960'].itemsToShow = 6
89
+ }
90
+ })
113
91
 
114
- switchGallery(value) {
115
- if (this.$mq === 'mobile') {
116
- this.gallery = false
117
- return
118
- }
119
- this.gallery = value
120
- if (value) {
121
- document.documentElement.classList.add('is-clipped')
122
- } else {
123
- document.documentElement.classList.remove('is-clipped')
124
- }
125
- }
126
- },
92
+ // Methods
93
+ const changeImage = () => {
94
+ //console.log('changeImage')
95
+ }
127
96
 
128
- mounted() {
129
- if (window.wkl_product) {
130
- this.$emit('update', window.wkl_product)
131
- }
132
- this.$bus.$on('changePhoto', (photoId) => {
133
- let imageIndex = _.findIndex(this.product?.images, { id: photoId })
134
- if (imageIndex >= 0) {
135
- this.activeImage = imageIndex
136
- }
137
- })
97
+ const getSrcset = (imgdata) => {
98
+ if (!imgdata.available_sizes) return
99
+ let srcset = []
100
+ imgdata.available_sizes.forEach(asize => {
101
+ srcset.push(`${asize.url} ${asize.width}w`)
102
+ })
103
+ return srcset.join(', ')
104
+ }
105
+
106
+ const switchGallery = (value) => {
107
+ if (mq.value === 'mobile') {
108
+ gallery.value = false
109
+ return
110
+ }
111
+ gallery.value = value
112
+ if (value) {
113
+ document.documentElement.classList.add('is-clipped')
114
+ } else {
115
+ document.documentElement.classList.remove('is-clipped')
116
+ }
117
+ }
118
+
119
+ const handleChangePhoto = (photoId) => {
120
+ let imageIndex = props.product?.images?.findIndex(img => img.id === photoId)
121
+ if (imageIndex >= 0) {
122
+ activeImage.value = imageIndex
138
123
  }
139
124
  }
125
+
126
+ // Lifecycle hooks
127
+ onMounted(() => {
128
+ if (window.wkl_product) {
129
+ emit('update', window.wkl_product)
130
+ }
131
+ eventBus.on('changePhoto', handleChangePhoto)
132
+ })
133
+
134
+ onBeforeUnmount(() => {
135
+ eventBus.off('changePhoto', handleChangePhoto)
136
+ })
140
137
  </script>
@@ -2,63 +2,125 @@
2
2
  <div class="quantity">
3
3
  <span class="quantity-label">{{ $t('global.quantity') }}</span>
4
4
  <div class="quantity-input">
5
- <button @click="decrease"><i class="fal fa-minus"></i></button>
6
- <input type="tel" @input="qtyInput" :value="value" />
7
- <button @click="increase"><i class="fal fa-plus"></i></button>
5
+ <button @click="decrease"><i class="fa fa-minus"></i></button>
6
+ <input type="tel" @input="qtyInput" :value="modelValue" />
7
+ <button @click="increase"><i class="fa fa-plus"></i></button>
8
8
  </div>
9
9
  </div>
10
10
  </template>
11
11
 
12
- <script>
13
- export default {
14
- name: 'Quantity',
15
- props: {
16
- value: {
17
- type: [Number, String],
18
- default: 1
19
- }
20
- },
21
- methods: {
22
- decrease() {
23
- let val = 0;
24
- if(this.value !== '') {
25
- val = this.value;
26
- }
27
- if (val >= 2) {
28
- this.$emit('input', val - 1)
29
- } else {
30
- this.$emit('input', 1)
31
- }
32
- },
33
- increase() {
34
- let val = 0;
35
- if(this.value !== '') {
36
- val = this.value;
37
- }
38
- this.$emit('input', val + 1)
39
- },
40
- qtyInput(event) {
41
- if(event.target.value.trim() === '') {
42
- this.$emit('input', '')
43
- return
44
- }
45
- let val = parseInt(event.target.value, 10)
46
- if (isNaN(val)) {
47
- event.target.value = 1
48
- this.value !== 1 && this.$emit('input', 1)
49
- return
50
- }
51
- if (val < 0) {
52
- event.target.value = 0
53
- this.value !== 0 && this.$emit('input', 0)
54
- } else if (val > 99) {
55
- event.target.value = 99
56
- this.value !== 0 && this.$emit('input', 99)
57
- } else {
58
- event.target.value = val
59
- this.value !== val && this.$emit('input', val)
60
- }
61
- }
12
+ <script setup>
13
+
14
+ defineOptions({ name: 'Quantity' })
15
+
16
+ const props = defineProps({
17
+ modelValue: {
18
+ type: [Number, String],
19
+ default: 1
20
+ }
21
+ })
22
+
23
+ const emit = defineEmits(['update:modelValue'])
24
+
25
+ const decrease = () => {
26
+ let val = 0
27
+ if (props.modelValue !== '') {
28
+ val = props.modelValue
29
+ }
30
+ if (val >= 2) {
31
+ emit('update:modelValue', val - 1)
32
+ } else {
33
+ emit('update:modelValue', 1)
34
+ }
35
+ }
36
+
37
+ const increase = () => {
38
+ let val = 0
39
+ if (props.modelValue !== '') {
40
+ val = props.modelValue
41
+ }
42
+ emit('update:modelValue', val + 1)
43
+ }
44
+
45
+ const qtyInput = (event) => {
46
+ if (event.target.value.trim() === '') {
47
+ emit('update:modelValue', '')
48
+ return
49
+ }
50
+ let val = parseInt(event.target.value, 10)
51
+ if (isNaN(val)) {
52
+ event.target.value = 1
53
+ props.modelValue !== 1 && emit('update:modelValue', 1)
54
+ return
55
+ }
56
+ if (val < 0) {
57
+ event.target.value = 0
58
+ props.modelValue !== 0 && emit('update:modelValue', 0)
59
+ } else if (val > 99) {
60
+ event.target.value = 99
61
+ props.modelValue !== 0 && emit('update:modelValue', 99)
62
+ } else {
63
+ event.target.value = val
64
+ props.modelValue !== val && emit('update:modelValue', val)
62
65
  }
63
66
  }
64
67
  </script>
68
+
69
+ <style scoped>
70
+ .quantity {
71
+ display: flex;
72
+ align-items: center;
73
+ gap: 0.5rem;
74
+ }
75
+
76
+ .quantity-label {
77
+ font-weight: 500;
78
+ }
79
+
80
+ .quantity-input {
81
+ display: flex;
82
+ align-items: center;
83
+ border: 1px solid #dbdbdb;
84
+ border-radius: 4px;
85
+ overflow: hidden;
86
+ }
87
+
88
+ .quantity-input button {
89
+ background: #f5f5f5;
90
+ border: none;
91
+ padding: 0.5rem 0.75rem;
92
+ cursor: pointer;
93
+ transition: background-color 0.2s;
94
+ display: flex;
95
+ align-items: center;
96
+ justify-content: center;
97
+ }
98
+
99
+ .quantity-input button:hover {
100
+ background: #e8e8e8;
101
+ }
102
+
103
+ .quantity-input button:active {
104
+ background: #d8d8d8;
105
+ }
106
+
107
+ .quantity-input input {
108
+ border: none;
109
+ width: 60px;
110
+ text-align: center;
111
+ padding: 0.5rem;
112
+ font-size: 1rem;
113
+ appearance: textfield;
114
+ -moz-appearance: textfield;
115
+ }
116
+
117
+ .quantity-input input::-webkit-outer-spin-button,
118
+ .quantity-input input::-webkit-inner-spin-button {
119
+ -webkit-appearance: none;
120
+ margin: 0;
121
+ }
122
+
123
+ .quantity-input input:focus {
124
+ outline: none;
125
+ }
126
+ </style>
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div>
3
- <b-modal :can-cancel="true" :active="showModal" @close="close" custom-class="wkl-modal-container quick-view-modal">
3
+ <b-modal :can-cancel="true" v-model="showModal" @close="close" custom-class="wkl-modal-container quick-view-modal">
4
4
  <div
5
5
  ref="qvModal"
6
6
  :class="['quick-view-main', 'product-main', 'product-container', { 'is-flower': product.class === 'flower' }]"
@@ -84,55 +84,62 @@
84
84
  </div>
85
85
  </template>
86
86
 
87
- <script>
87
+ <script setup>
88
+ import { ref, onMounted, onBeforeUnmount } from 'vue'
89
+ import { useInitialState } from '../../composables/globals'
88
90
  import config from '../../config'
89
91
  import { request } from '../../api'
92
+ import { eventBus } from '../../utils/event-bus'
90
93
 
91
- import AddToCart from '../../components/Product/AddToCart'
92
- import Price from '../../components/Product/Price'
93
- import ProductImages from '../../components/Product/ProductImages'
94
- import Variants from '../../components/Product/Variants'
95
-
96
- export default {
97
- name: 'QuickView',
98
- components: { AddToCart, Price, ProductImages, Variants },
99
-
100
- data() {
101
- return {
102
- showModal: false,
103
- isLoading: false,
104
- product: {},
105
- variant_id: null,
106
- meta: {}
107
- }
108
- },
109
-
110
- methods: {
111
- close() {
112
- this.$set(this, 'product', {})
113
- this.$set(this, 'meta', {})
114
- this.showModal = false
115
- }
116
- },
117
-
118
- mounted() {
119
- this.$bus.$on('quickView', async (product_id, variant_id) => {
120
- this.showModal = true
121
- this.isLoading = true
122
- if(variant_id) {
123
- this.variant_id = variant_id
124
- }
125
- let resp = await request({
126
- baseURL: config.BASE_URL,
127
- url: '/products/' + product_id
128
- })
129
- this.isLoading = false
130
- this.$set(this, 'product', resp.data.product_resource)
131
- this.product = resp.data.product_resource
132
- this.meta = resp.data.meta
133
- })
94
+ import AddToCart from './AddToCart.vue'
95
+ import Price from './Price.vue'
96
+ import ProductImages from './ProductImages.vue'
97
+ import Variants from './Variants.vue'
98
+
99
+ defineOptions({ name: 'QuickView' })
100
+
101
+ const initialState = useInitialState()
102
+
103
+ // Template refs
104
+ const qvModal = ref(null)
105
+
106
+ // Reactive state
107
+ const showModal = ref(false)
108
+ const isLoading = ref(false)
109
+ const product = ref({})
110
+ const variant_id = ref(null)
111
+ const meta = ref({})
112
+
113
+ // Methods
114
+ const close = () => {
115
+ product.value = {}
116
+ meta.value = {}
117
+ showModal.value = false
118
+ }
119
+
120
+ const handleQuickView = async (product_id, vid) => {
121
+ showModal.value = true
122
+ isLoading.value = true
123
+ if (vid) {
124
+ variant_id.value = vid
134
125
  }
126
+ let resp = await request({
127
+ baseURL: config.BASE_URL,
128
+ url: '/products/' + product_id
129
+ })
130
+ isLoading.value = false
131
+ product.value = resp.data.product_resource
132
+ meta.value = resp.data.meta
135
133
  }
134
+
135
+ // Lifecycle hooks
136
+ onMounted(() => {
137
+ eventBus.on('quickView', handleQuickView)
138
+ })
139
+
140
+ onBeforeUnmount(() => {
141
+ eventBus.off('quickView', handleQuickView)
142
+ })
136
143
  </script>
137
144
 
138
145
  <style scoped></style>