@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.
- package/MIGRATION_GUIDE.md +261 -0
- package/api/product.js +1 -0
- package/api/request.js +9 -4
- package/api/user.js +1 -1
- package/components/Account/AccountDashboard.vue +101 -101
- package/components/Account/AccountStore.js +57 -31
- package/components/Account/AffiliateReport.vue +56 -60
- package/components/Account/{OrderDetail.vue → Orders/OrderDetail.vue} +44 -30
- package/components/Account/Orders/Orders.vue +124 -0
- package/components/Account/{AccountSettings.vue → Settings/AccountSettings.vue} +4 -4
- package/components/Account/Settings/ChangeEmail.vue +136 -0
- package/components/Account/Settings/ChangeName.vue +82 -0
- package/components/Account/Settings/ChangePassword.vue +91 -0
- package/components/Address/Address.vue +38 -57
- package/components/Address/AddressBook.vue +77 -57
- package/components/Address/AddressSelect.vue +94 -87
- package/components/Address/Edit.vue +253 -265
- package/components/Address/PostalCode.vue +22 -21
- package/components/AgeGate.vue +11 -5
- package/components/Auth/Login.vue +62 -44
- package/components/Auth/Register.vue +82 -60
- package/components/Auth/ResetPassword.vue +45 -30
- package/components/Cart/AgeVerification/AgeChecker.vue +3 -3
- package/components/Cart/CartBadge.vue +15 -4
- package/components/Cart/CartBox.vue +19 -11
- package/components/Cart/CartItem.vue +3 -3
- package/components/Cart/CartMode.vue +6 -5
- package/components/Cart/CartPreview.vue +24 -18
- package/components/Cart/CreditCard/Everyware.vue +10 -10
- package/components/Cart/CreditCard/ExtendedCreditCard.vue +5 -5
- package/components/Cart/CreditCard/SquarePay.vue +18 -16
- package/components/Cart/CreditCard/StandardCreditCard.vue +9 -9
- package/components/Cart/Delivery/Delivery.vue +16 -12
- package/components/Cart/Delivery/DeliveryAddress.vue +1 -1
- package/components/Cart/Delivery/DeliveryMethods.vue +1 -1
- package/components/Cart/Delivery/DeliveryOptions.vue +15 -9
- package/components/Cart/Delivery/DeliveryTypes.vue +8 -5
- package/components/Cart/Delivery/ReservationSlots.vue +14 -8
- package/components/Cart/Disclaimer.vue +1 -1
- package/components/Cart/OrderConfirmation.vue +1 -1
- package/components/Cart/Payment/Payment.vue +37 -33
- package/components/Cart/Payment/PaymentMethods.vue +6 -4
- package/components/Cart/ReviewAndSubmit.vue +9 -7
- package/components/Cart/ShoppingCart.vue +42 -31
- package/components/Cart/Store/actions.js +1 -1
- package/components/Cart/Store/getters.js +2 -1
- package/components/Cart/Store/index.js +1 -1
- package/components/Cart/Store/mutations.js +7 -5
- package/components/Cart/UserIdentity.vue +1 -1
- package/components/Category/CategoryFilter.vue +128 -114
- package/components/Category/CategorySort.vue +44 -32
- package/components/Category/LoadMore.vue +39 -23
- package/components/DeliverTo.vue +10 -15
- package/components/DeliveryNotice.vue +72 -68
- package/components/DobInput.vue +23 -23
- package/components/Gmaps/GmapsAutocomplete.vue +139 -78
- package/components/Gmaps/GmapsLocations.vue +1 -1
- package/components/Gmaps/GmapsSingleLocation.vue +121 -87
- package/components/ModalContainer/ModalContainer.vue +12 -9
- package/components/ModalContainer/index.js +61 -18
- package/components/Product/AddToCart.vue +237 -221
- package/components/Product/BoxAddToCart.vue +114 -86
- package/components/Product/Compare.vue +68 -48
- package/components/Product/CompareBox.vue +128 -123
- package/components/Product/Lookup.vue +92 -65
- package/components/Product/Photo.vue +105 -66
- package/components/Product/Price.vue +64 -43
- package/components/Product/ProductAutocomplete.vue +52 -57
- package/components/Product/ProductBox.vue +61 -38
- package/components/Product/ProductImages.vue +83 -86
- package/components/Product/Quantity.vue +115 -53
- package/components/Product/QuickView.vue +52 -45
- package/components/Product/RelatedProducts.vue +88 -23
- package/components/Product/SKU.vue +27 -8
- package/components/Product/Variants.vue +335 -341
- package/components/Product/reviews-questions/ProductQuestions.vue +226 -198
- package/components/Product/reviews-questions/ProductReviews.vue +122 -107
- package/components/Product/reviews-questions/Review.vue +54 -59
- package/components/Product/reviews-questions/ReviewForm.vue +222 -170
- package/components/Product/reviews-questions/ReviewImages.vue +197 -216
- package/components/Product/reviews-questions/Vote.vue +83 -57
- package/components/QuantityInput.vue +18 -8
- package/components/RangeInput.vue +15 -8
- package/components/Recaptcha.vue +8 -1
- package/components/SelectShippingCountry.vue +81 -62
- package/components/TimedOffer.vue +59 -74
- package/composables/globals.js +53 -0
- package/config.js +5 -2
- package/index.js +41 -10
- package/install.js +75 -0
- package/locales/en.json +2 -1
- package/locales/sr.json +2 -1
- package/package.json +43 -30
- package/utils/directives.js +28 -45
- package/utils/event-bus.js +56 -0
- package/utils/filters.js +24 -7
- package/utils/{gmaps.js → google/gmaps.js} +43 -10
- package/utils/{google-analytics-eec.js → google/google-analytics-eec.js} +7 -7
- package/babel.config.js +0 -5
- package/components/Account/ChangeEmail.vue +0 -133
- package/components/Account/ChangeName.vue +0 -92
- package/components/Account/ChangePassword.vue +0 -94
- package/components/Account/CreditCards.vue +0 -18
- package/components/Account/Orders.vue +0 -110
- package/components/Account/Settings.vue +0 -18
- package/components/Cart/Delivery/DeliveryAddressGuest.spec.js +0 -128
- package/components/Cart/Delivery/DeliveryTypes.spec.js +0 -83
- package/components/Cart/PCIBadge/SecurityMetrics.vue +0 -11
- package/components/Instagram.vue +0 -49
- package/components/ProductImageModal.vue +0 -41
- package/jest.config.js +0 -16
- package/test/e2e/.babelrc.js +0 -8
- package/test/e2e/.eslintrc.js +0 -11
- package/test/e2e/accAuth.spec.js +0 -64
- package/test/e2e/ageGate.spec.js +0 -26
- package/test/e2e/checkout.spec.js +0 -106
- package/test/e2e/compare.spec.js +0 -52
- package/test/e2e/config/data.js +0 -21
- package/test/e2e/config/routes.js +0 -11
- package/test/e2e/region.spec.js +0 -46
- package/test/e2e/search.spec.js +0 -32
- package/tests/vueBuefy.js +0 -4
- 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" @
|
|
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" @
|
|
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
|
-
<
|
|
44
|
-
<div v-if="img
|
|
45
|
-
<div class="image-placeholder
|
|
46
|
-
<
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
</
|
|
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/*" @
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
109
|
-
rate(rating) {
|
|
110
|
-
this.validationErrors.rating = ''
|
|
111
|
-
this.review.rating = rating
|
|
112
|
-
},
|
|
107
|
+
const emit = defineEmits(['success', 'error', 'close'])
|
|
113
108
|
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
122
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
|
|
134
|
+
// Methods
|
|
135
|
+
const rate = (rating) => {
|
|
136
|
+
validationErrors.value.rating = ''
|
|
137
|
+
review.value.rating = rating
|
|
138
|
+
}
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
|
|
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
|
-
|
|
168
|
-
|
|
169
|
-
dataurl: imageDataURL
|
|
170
|
-
})
|
|
168
|
+
try {
|
|
169
|
+
const response = await Product.postImages(imageData, config)
|
|
171
170
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
|
|
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
|
-
|
|
194
|
-
|
|
195
|
-
left: 0,
|
|
196
|
-
behavior: 'smooth'
|
|
197
|
-
})
|
|
198
|
-
},
|
|
216
|
+
imageIndex.value++
|
|
217
|
+
}
|
|
199
218
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
219
|
+
document.getElementById('reviews-form')?.scroll({
|
|
220
|
+
top: 10000,
|
|
221
|
+
left: 0,
|
|
222
|
+
behavior: 'smooth'
|
|
223
|
+
})
|
|
224
|
+
}
|
|
205
225
|
|
|
206
|
-
|
|
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
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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:
|
|
238
|
+
message: $t('review.thanks'),
|
|
247
239
|
position: 'is-top',
|
|
248
|
-
type: 'is-
|
|
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
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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>
|