@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
@@ -3,7 +3,7 @@
3
3
  <div class="columns filter-sort-c">
4
4
  <div class="column filter-sort">
5
5
  <span>{{ $t('review.filter') }}</span>
6
- <b-select @input="changeFilter" :placeholder="$t('review.all')" v-model="filterParam.f" size="is-small">
6
+ <b-select v-model="filterParam.f" :placeholder="$t('review.all')" @update:model-value="changeFilter" size="is-small">
7
7
  <option v-for="filter in topics" :value="filter" :key="filter">
8
8
  {{ filter }}
9
9
  </option>
@@ -11,7 +11,7 @@
11
11
  </div>
12
12
  <div class="column filter-sort">
13
13
  <span>{{ $t('review.lSortBy') }}</span>
14
- <b-select @input="changeFilter" :placeholder="$t('review.mostHelpful')" v-model="filterParam.sort" size="is-small">
14
+ <b-select v-model="filterParam.sort" :placeholder="$t('review.mostHelpful')" @update:model-value="changeFilter" size="is-small">
15
15
  <option v-for="option in sorting" :value="option.value" :key="option.value">
16
16
  {{ option.name }}
17
17
  </option>
@@ -19,13 +19,13 @@
19
19
  </div>
20
20
  </div>
21
21
 
22
- <div ref="list" class="questions-list">
22
+ <div ref="listRef" class="questions-list">
23
23
  <div class="question" v-for="question in list.data" :key="question.id">
24
24
  <div class="columns">
25
25
  <div class="column">
26
26
  <div class="is-flex" style="justify-content: space-between">
27
27
  <div>{{ question.name }}</div>
28
- <div style="color: #c0c0c0">{{ question.created_at | date }}</div>
28
+ <div style="color: #c0c0c0">{{ $filters.date(question.created_at) }}</div>
29
29
  </div>
30
30
  <div class="subtitle has-text-weight-semibold">
31
31
  {{ question.body }}
@@ -37,7 +37,7 @@
37
37
  <div class="question-answer" v-for="(answer, i) in question.replies" :key="answer.id">
38
38
  <div class="columns">
39
39
  <div class="column answer-user">{{ initialState.site_name }}</div>
40
- <div class="column has-text-right answer-date">{{ answer.created_at | date }}</div>
40
+ <div class="column has-text-right answer-date">{{ $filters.date(answer.created_at) }}</div>
41
41
  </div>
42
42
  <div class="columns">
43
43
  <div class="column answer-body">
@@ -55,7 +55,7 @@
55
55
  <b-pagination
56
56
  v-if="list.meta && list.meta.total > 20"
57
57
  :total="list.meta.total"
58
- :current.sync="list.meta.current_page"
58
+ v-model:current="list.meta.current_page"
59
59
  :per-page="list.meta.per_page"
60
60
  @change="changePage"
61
61
  aria-next-label="Next page"
@@ -71,221 +71,249 @@
71
71
  <div class="no-reviews" v-if="list.data && !list.data.length"> {{ $t('review.question.noQuestions') }} </div>
72
72
  </template>
73
73
 
74
- <b-modal :active.sync="questionModal" :can-cancel="['x']">
75
- <form action>
76
- <div class="modal-card">
77
- <header class="modal-card-head">
78
- <p class="modal-card-title">{{ $t('review.question.askQuestion') }}</p>
79
- </header>
80
- <section class="modal-card-body">
81
- <b-field :label="$t('review.question.chooseTopic')" label-position="inside" :type="{ 'is-danger': errors.subject }" :message="errors.subject">
82
- <b-select v-model="question.subject" expanded>
83
- <option v-for="option in topics" :value="option" :key="option">
84
- {{ option }}
85
- </option>
86
- </b-select>
87
- </b-field>
74
+ <Teleport to="body">
75
+ <b-modal v-model="questionModal" :can-cancel="['x']">
76
+ <form action>
77
+ <div class="modal-card">
78
+ <header class="modal-card-head">
79
+ <p class="modal-card-title">{{ $t('review.question.askQuestion') }}</p>
80
+ </header>
81
+ <section class="modal-card-body">
82
+ <b-field :label="$t('review.question.chooseTopic')" label-position="inside" :type="{ 'is-danger': errors.subject }" :message="errors.subject">
83
+ <b-select v-model="question.subject" expanded>
84
+ <option v-for="option in topics" :value="option" :key="option">
85
+ {{ option }}
86
+ </option>
87
+ </b-select>
88
+ </b-field>
88
89
 
89
- <b-field :label="$t('review.question.question')" label-position="inside" :type="{ 'is-danger': errors.body }" :message="errors.body">
90
- <b-input v-model="question.body" type="textarea" />
91
- </b-field>
92
- </section>
93
- <footer class="modal-card-foot">
94
- <b-button :loading="loading" type="is-primary" @click="askQuestion">{{ $t('review.question.askQuestion') }}</b-button>
95
- <b-button class="button" type="button" @click="questionModal = false">{{ $t('global.cancel') }}</b-button>
96
- </footer>
97
- </div>
98
- </form>
99
- </b-modal>
90
+ <b-field :label="$t('review.question.question')" label-position="inside" :type="{ 'is-danger': errors.body }" :message="errors.body">
91
+ <b-input v-model="question.body" type="textarea" />
92
+ </b-field>
93
+ </section>
94
+ <footer class="modal-card-foot">
95
+ <b-button :loading="loading" type="is-primary" @click="askQuestion">{{ $t('review.question.askQuestion') }}</b-button>
96
+ <b-button class="button" type="button" @click="questionModal = false">{{ $t('global.cancel') }}</b-button>
97
+ </footer>
98
+ </div>
99
+ </form>
100
+ </b-modal>
101
+ </Teleport>
100
102
 
101
- <b-modal :active.sync="answerModal">
102
- <form>
103
- <div class="modal-card">
104
- <header class="modal-card-head">
105
- <p class="modal-card-title">{{ $t('review.answerQuestion') }}</p>
106
- </header>
107
- <section class="modal-card-body">
108
- <b-field :label="$t('review.question.answer')" label-position="inside" :type="{ 'is-danger': errors.body }" :message="errors.body">
109
- <b-input v-model="reply.body" type="textarea" />
110
- </b-field>
111
- </section>
112
- <footer class="modal-card-foot">
113
- <b-button :loading="loading" type="is-primary" @click="postReply">{{ $t('review.question.submitAnswer') }}</b-button>
114
- <b-button class="button" type="button" @click="answerModal = false">{{ $t('global.cancel') }}</b-button>
115
- </footer>
116
- </div>
117
- </form>
118
- </b-modal>
103
+ <Teleport to="body">
104
+ <b-modal v-model="answerModal">
105
+ <form>
106
+ <div class="modal-card">
107
+ <header class="modal-card-head">
108
+ <p class="modal-card-title">{{ $t('review.answerQuestion') }}</p>
109
+ </header>
110
+ <section class="modal-card-body">
111
+ <b-field :label="$t('review.question.answer')" label-position="inside" :type="{ 'is-danger': errors.body }" :message="errors.body">
112
+ <b-input v-model="reply.body" type="textarea" />
113
+ </b-field>
114
+ </section>
115
+ <footer class="modal-card-foot">
116
+ <b-button :loading="loading" type="is-primary" @click="postReply">{{ $t('review.question.submitAnswer') }}</b-button>
117
+ <b-button class="button" type="button" @click="answerModal = false">{{ $t('global.cancel') }}</b-button>
118
+ </footer>
119
+ </div>
120
+ </form>
121
+ </b-modal>
122
+ </Teleport>
119
123
  </div>
120
124
  </template>
121
125
 
122
- <script>
126
+ <script setup>
127
+ import { ref, computed, onMounted, onBeforeUnmount, getCurrentInstance } from 'vue'
128
+ import { useBuefy, useBus, useInitialState, useT } from '../../../composables/globals'
123
129
  import { ProductQuestions } from '../../../api'
124
- import Vote from './Vote'
130
+ import Vote from './Vote.vue'
125
131
 
126
- export default {
127
- name: 'ProductQuestions',
132
+ const buefy = useBuefy()
133
+ const bus = useBus()
134
+ const { t } = useT()
135
+ const initialState = useInitialState()
136
+ // Host app's root instance and its openModal() helper (provided by the consuming app)
137
+ const instance = getCurrentInstance()
128
138
 
129
- components: { Vote },
139
+ // Get product ID from global (Vue 3 compatible)
140
+ const productId = typeof window !== 'undefined' && window.wkl_product ? window.wkl_product.id : null
130
141
 
131
- data() {
132
- return {
133
- filterParam: {
134
- f: this.$t('review.question.topics.all'),
135
- sort: 'newest'
136
- },
137
- list: [],
138
- errors: {},
139
- productId: window.wkl_product.id,
140
- question: {
141
- type: 'question',
142
- subject: '',
143
- product_id: window.wkl_product.id
144
- },
145
- reply: {},
146
- voteResult: {},
147
- toggleAnswers: false,
148
- questionModal: false,
149
- answerModal: false,
150
- loading: false,
151
- errorLoading: ''
152
- }
153
- },
142
+ // Refs
143
+ const list = ref({ data: [], meta: {} })
144
+ const listRef = ref(null)
145
+ const errors = ref({})
146
+ const voteResult = ref({})
147
+ const questionModal = ref(false)
148
+ const answerModal = ref(false)
149
+ const loading = ref(false)
150
+ const errorLoading = ref('')
154
151
 
155
- computed: {
156
- topics() {
157
- return [
158
- this.$t('review.question.topics.all'),
159
- this.$t('review.question.topics.specifications'),
160
- this.$t('review.question.topics.brand'),
161
- this.$t('review.question.topics.usage'),
162
- this.$t('review.question.topics.shipping'),
163
- this.$t('review.question.topics.other')
164
- ]
165
- },
166
- sorting() {
167
- return [
168
- { value: 'newest', name: this.$t('review.sortBy.newest') },
169
- { value: 'oldest', name: this.$t('review.sortBy.oldest') },
170
- { value: 'rating-low', name: this.$t('review.sortBy.ratingLow') },
171
- { value: 'rating-high', name: this.$t('review.sortBy.ratingHigh') },
172
- { value: 'most-helpful', name: this.$t('review.sortBy.mostHelpful') }
173
- ]
174
- }
175
- },
152
+ const filterParam = ref({
153
+ f: t('review.question.topics.all'),
154
+ sort: 'newest'
155
+ })
176
156
 
177
- methods: {
178
- changeFilter() {
179
- this.getQuestions(this.filterParam)
180
- },
157
+ const question = ref({
158
+ type: 'question',
159
+ subject: '',
160
+ body: '',
161
+ product_id: productId
162
+ })
181
163
 
182
- async submitVote(item_id, vote) {
183
- try {
184
- let resp = await ProductQuestions.vote(item_id, { vote })
185
- this.$set(this.voteResult, item_id, {
186
- status: 1,
187
- msg: this.$t('review.voteSubmitted'),
188
- data: resp.data.data
189
- })
190
- } catch (err) {
191
- this.$set(this.voteResult, item_id, {
192
- status: 0,
193
- msg: err.error || this.$t('review.voteSubmitError')
194
- })
195
- }
196
- },
164
+ const reply = ref({
165
+ id: null,
166
+ body: ''
167
+ })
197
168
 
198
- attachModalToBody() { //fixes z-index issues
199
- const modal = document.getElementsByClassName('modal');
200
- if(modal.length) {
201
- document.body.insertAdjacentElement('afterbegin', modal[0])
202
- }
203
- },
169
+ // Computed
170
+ const topics = computed(() => {
171
+ return [
172
+ t('review.question.topics.all'),
173
+ t('review.question.topics.specifications'),
174
+ t('review.question.topics.brand'),
175
+ t('review.question.topics.usage'),
176
+ t('review.question.topics.shipping'),
177
+ t('review.question.topics.other')
178
+ ]
179
+ })
204
180
 
205
- openQuestion() {
206
- if (this.initialState.user) {
207
- this.questionModal = true
208
- this.$nextTick(() => {
209
- this.attachModalToBody()
210
- })
211
- } else {
212
- this.openModal('Login')
213
- }
214
- },
181
+ const sorting = computed(() => {
182
+ return [
183
+ { value: 'newest', name: t('review.sortBy.newest') },
184
+ { value: 'oldest', name: t('review.sortBy.oldest') },
185
+ { value: 'rating-low', name: t('review.sortBy.ratingLow') },
186
+ { value: 'rating-high', name: t('review.sortBy.ratingHigh') },
187
+ { value: 'most-helpful', name: t('review.sortBy.mostHelpful') }
188
+ ]
189
+ })
190
+
191
+ // Methods
192
+ const changeFilter = () => {
193
+ getQuestions(filterParam.value)
194
+ }
195
+
196
+ const submitVote = async (item_id, vote) => {
197
+ try {
198
+ const resp = await ProductQuestions.vote(item_id, { vote })
199
+ // Vue 3: reactive assignment instead of $set
200
+ voteResult.value[item_id] = {
201
+ status: 1,
202
+ msg: t('review.voteSubmitted'),
203
+ data: resp.data.data
204
+ }
205
+ } catch (err) {
206
+ voteResult.value[item_id] = {
207
+ status: 0,
208
+ msg: err.error || t('review.voteSubmitError')
209
+ }
210
+ }
211
+ }
212
+
213
+ const openQuestion = () => {
214
+ if (initialState.user) {
215
+ questionModal.value = true
216
+ } else {
217
+ instance.proxy.openModal?.('Login')
218
+ }
219
+ }
215
220
 
216
- changePage(page) {
217
- this.filterParam.page = page
218
- this.getQuestions(this.filterParam)
219
- document.querySelector('.b-tabs').scrollIntoView({ behavior: 'smooth' })
220
- },
221
+ const changePage = (page) => {
222
+ filterParam.value.page = page
223
+ getQuestions(filterParam.value)
224
+ const tabsElement = document.querySelector('.b-tabs')
225
+ if (tabsElement) {
226
+ tabsElement.scrollIntoView({ behavior: 'smooth' })
227
+ }
228
+ }
221
229
 
222
- async getQuestions(filter) {
223
- this.loading = true
224
- this.errorLoading = ''
225
- let loading = this.$buefy.loading.open({ container: this.$refs.list })
226
- try {
227
- let { data } = await ProductQuestions.getAll(this.productId, filter)
228
- this.list = data
229
- } catch (e) {
230
- this.errorLoading = this.$t('review.question.errorLoading', [e.message])
231
- console.log('Cannot load questions', e.message, this.errorLoading)
232
- } finally {
233
- //console.log('set question list ', data)
234
- this.loading = false
235
- loading.close()
236
- }
237
- },
230
+ const getQuestions = async (filter) => {
231
+ loading.value = true
232
+ errorLoading.value = ''
233
+
234
+ const loadingComponent = buefy.loading.open({ container: listRef.value })
235
+
236
+ try {
237
+ const { data } = await ProductQuestions.getAll(productId, filter)
238
+ list.value = data
239
+ } catch (e) {
240
+ errorLoading.value = t('review.question.errorLoading', [e.message])
241
+ console.log('Cannot load questions', e.message, errorLoading.value)
242
+ } finally {
243
+ loading.value = false
244
+ loadingComponent.close()
245
+ }
246
+ }
238
247
 
239
- async askQuestion() {
240
- this.loading = true
248
+ const askQuestion = async () => {
249
+ loading.value = true
241
250
 
242
- try {
243
- await ProductQuestions.sendQuestion(this.productId, this.question)
244
- this.$buefy.snackbar.open(this.$t('review.question.submitted'))
245
- setTimeout(async () => {
246
- await this.getQuestions(this.filterParam)
247
- }, 1000)
251
+ try {
252
+ await ProductQuestions.sendQuestion(productId, question.value)
253
+ buefy.snackbar.open(t('review.question.submitted'))
254
+
255
+ setTimeout(async () => {
256
+ await getQuestions(filterParam.value)
257
+ }, 1000)
248
258
 
249
- this.questionModal = false
250
- this.errors = {}
251
- this.question.subject = ''
252
- this.question.body = ''
253
- } catch (err) {
254
- this.errors = err.errors
255
- } finally {
256
- this.loading = false
257
- }
258
- },
259
+ questionModal.value = false
260
+ errors.value = {}
261
+ question.value.subject = ''
262
+ question.value.body = ''
263
+ } catch (err) {
264
+ errors.value = err.errors || {}
265
+ } finally {
266
+ loading.value = false
267
+ }
268
+ }
259
269
 
260
- openAnswerModal(id) {
261
- wkl_initial_state.user ? (this.answerModal = true) : this.openModal('Login')
262
- this.reply.id = id
263
- },
270
+ const openAnswerModal = (id) => {
271
+ if (initialState.user) {
272
+ answerModal.value = true
273
+ } else {
274
+ instance.proxy.openModal?.('Login')
275
+ }
276
+ reply.value.id = id
277
+ }
264
278
 
265
- async postReply() {
266
- this.loading = true
279
+ const postReply = async () => {
280
+ loading.value = true
267
281
 
268
- try {
269
- await ProductQuestions.sendReply(this.reply.id, this.reply)
270
- this.$buefy.snackbar.open(this.$t('review.question.answerSubmitted'))
271
- this.answerModal = false
272
- this.errors = {}
273
- } catch (err) {
274
- this.$buefy.snackbar.open(err.message, { duration: 5000 })
275
- } finally {
276
- this.loading = false
277
- }
278
- }
279
- },
282
+ try {
283
+ await ProductQuestions.sendReply(reply.value.id, reply.value)
284
+ buefy.snackbar.open(t('review.question.answerSubmitted'))
285
+ answerModal.value = false
286
+ errors.value = {}
287
+ } catch (err) {
288
+ buefy.snackbar.open({ message: err.message, duration: 5000 })
289
+ } finally {
290
+ loading.value = false
291
+ }
292
+ }
280
293
 
281
- mounted() {
282
- this.getQuestions(this.filterParam)
283
- this.$bus.$on('openQuestion', () => {
284
- //console.log('rq active tab', this.$root.reviewsQuestionsActiveTab)
285
- this.$root.reviewsQuestionsActiveTab = 1
286
- this.openQuestion()
287
- console.log('open question event')
288
- })
294
+ const onOpenQuestion = () => {
295
+ const root = instance.proxy.$root
296
+ if (root && root.reviewsQuestionsActiveTab !== undefined) {
297
+ root.reviewsQuestionsActiveTab = 1
289
298
  }
299
+ openQuestion()
290
300
  }
301
+
302
+ // Lifecycle
303
+ onMounted(() => {
304
+ getQuestions(filterParam.value)
305
+
306
+ bus.on('openQuestion', onOpenQuestion)
307
+ })
308
+
309
+ onBeforeUnmount(() => {
310
+ bus.off('openQuestion', onOpenQuestion)
311
+ })
312
+
313
+ // Expose refs for template
314
+ defineExpose({
315
+ list,
316
+ listRef,
317
+ openQuestion
318
+ })
291
319
  </script>