@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
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <b-modal :can-cancel="false" :active="showModal">
2
+ <b-modal :can-cancel="false" v-model="showModal">
3
3
  <div class="wkl-agate-main">
4
4
  <div class="agate-title">Please confirm your age</div>
5
5
  <p class="wkl-agate-age">
@@ -30,6 +30,7 @@
30
30
 
31
31
  <script>
32
32
  import Cookie from 'js-cookie'
33
+ import { eventBus } from '../utils/event-bus'
33
34
 
34
35
  export default {
35
36
  name: 'AgeGate',
@@ -74,6 +75,11 @@ export default {
74
75
 
75
76
  agreject() {
76
77
  window.location.href = 'https://www.google.com/'
78
+ },
79
+
80
+ handleShowAgeGate() {
81
+ console.log('receiving sag')
82
+ this.showModal = true
77
83
  }
78
84
  },
79
85
 
@@ -93,11 +99,11 @@ export default {
93
99
  this.showModal = true
94
100
  }
95
101
  }, 100)
102
+ eventBus.on('showAgeGate', this.handleShowAgeGate)
103
+ },
96
104
 
97
- this.$bus.$on('showAgeGate', () => {
98
- console.log('receiving sag')
99
- this.showModal = true
100
- })
105
+ beforeUnmount() {
106
+ eventBus.off('showAgeGate', this.handleShowAgeGate)
101
107
  }
102
108
  }
103
109
  </script>
@@ -9,7 +9,7 @@
9
9
  <section class="modal-card-body">
10
10
  <div v-if="showContinueAsGuest" class="continue-as-guest">
11
11
  <div>
12
- <button name="continue_as_guest" type="button" class="button is-fullwidth has-text-weight-bold" @click.prevent="$bus.$emit('guestMode', 'On')">
12
+ <button name="continue_as_guest" type="button" class="button is-fullwidth has-text-weight-bold" @click.prevent="bus.emit('guestMode', 'On')">
13
13
  {{ $t('auth.continueAsGuest') }}
14
14
  </button>
15
15
  </div>
@@ -67,11 +67,11 @@
67
67
  </footer>
68
68
  </form>
69
69
 
70
- <b-modal :active="showResetPasswordDialog" @close="showResetPasswordDialog = false" custom-class="wkl-modal-container" :can-cancel="['escape', 'outside']">
70
+ <b-modal v-model="showResetPasswordDialog" custom-class="wkl-modal-container" :can-cancel="['escape', 'outside']">
71
71
  <ResetPassword @close="showResetPasswordDialog = false" />
72
72
  </b-modal>
73
73
 
74
- <b-modal :active="showCreateAccountDialog" @close="showCreateAccountDialog = false" custom-class="wkl-modal-container" :can-cancel="['escape', 'outside']">
74
+ <b-modal v-model="showCreateAccountDialog" custom-class="wkl-modal-container" :can-cancel="['escape', 'outside']">
75
75
  <Register :title="createAccountTitle" :get-source="getSource" @close="showCreateAccountDialog = false" />
76
76
  </b-modal>
77
77
 
@@ -79,11 +79,13 @@
79
79
  </template>
80
80
 
81
81
  <script>
82
-
82
+ import { ref, onMounted } from 'vue'
83
+ import config from '../../config'
83
84
  import { request } from '../../api'
85
+ import { useBus, useMq } from '../../composables/globals'
84
86
 
85
- import ResetPassword from './ResetPassword'
86
- import Register from './Register'
87
+ import ResetPassword from './ResetPassword.vue'
88
+ import Register from './Register.vue'
87
89
 
88
90
  export default {
89
91
  name: 'Login',
@@ -109,64 +111,80 @@ export default {
109
111
  default: 'Create Account'
110
112
  }
111
113
  },
112
- data() {
113
- return {
114
- loading: false,
115
- errors: {},
116
- email: '',
117
- password: '',
118
- showResetPasswordDialog: false,
119
- showCreateAccountDialog: false
120
- }
121
- },
122
-
123
- methods: {
124
- async doLogin() {
125
- this.loading = true
114
+ emits: ['close'],
115
+ setup(props, { emit }) {
116
+ const bus = useBus()
117
+ const mq = useMq()
118
+
119
+ // Reactive state
120
+ const loading = ref(false)
121
+ const errors = ref({})
122
+ const email = ref('')
123
+ const password = ref('')
124
+ const showResetPasswordDialog = ref(false)
125
+ const showCreateAccountDialog = ref(false)
126
+ const loginEmail = ref(null)
127
+
128
+ // Methods
129
+ const doLogin = async () => {
130
+ loading.value = true
126
131
  try {
127
132
  let response = await request({
128
- baseURL: this.getConfig('BASE_URL'),
133
+ baseURL: config.BASE_URL,
129
134
  url: '/login',
130
135
  method: 'post',
131
- data: { email: this.email, password: this.password, scope: 'customer' }
136
+ data: { email: email.value, password: password.value, scope: 'customer' }
132
137
  })
133
- this.loading = false
138
+ loading.value = false
134
139
  if (response.status === 200) {
135
- if (this.redirectHandler) {
136
- this.redirectHandler()
140
+ if (props.redirectHandler) {
141
+ props.redirectHandler()
137
142
  } else {
138
143
  window.location.href = '/account'
139
144
  }
140
145
  }
141
146
  } catch (error) {
142
- this.loading = false
143
- this.errors = error.errors
147
+ loading.value = false
148
+ errors.value = error.errors || {}
144
149
  }
145
- },
150
+ }
146
151
 
147
- clearError(field) {
148
- if (this.errors[field]) {
149
- this.errors[field] = ''
152
+ const clearError = (field) => {
153
+ if (errors.value[field]) {
154
+ errors.value[field] = ''
150
155
  }
151
156
  }
152
- },
153
157
 
154
- mounted() {
158
+ // Lifecycle hooks
159
+ onMounted(() => {
160
+ let loginUrl = new URL(window.location.href)
155
161
 
156
- let loginUrl = new URL(window.location.href)
162
+ let showLostPassword = loginUrl.searchParams.get('lost-password')
163
+ if(showLostPassword === '') {
164
+ showResetPasswordDialog.value = true
165
+ }
157
166
 
158
- let showLostPassword = loginUrl.searchParams.get('lost-password')
159
- if(showLostPassword === '') {
160
- this.showResetPasswordDialog = true
161
- }
167
+ let showCreateAccount = loginUrl.searchParams.get('create-account')
168
+ if(showCreateAccount === '') {
169
+ showCreateAccountDialog.value = true
170
+ }
162
171
 
163
- let showCreateAccount = loginUrl.searchParams.get('create-account')
164
- if(showCreateAccount === '') {
165
- this.showCreateAccountDialog = true
166
- }
172
+ if (mq.value !== 'mobile') {
173
+ loginEmail.value?.focus()
174
+ }
175
+ })
167
176
 
168
- if (this.$mq !== 'mobile') {
169
- this.$refs.loginEmail.focus()
177
+ return {
178
+ loading,
179
+ errors,
180
+ email,
181
+ password,
182
+ showResetPasswordDialog,
183
+ showCreateAccountDialog,
184
+ loginEmail,
185
+ doLogin,
186
+ clearError,
187
+ bus
170
188
  }
171
189
  }
172
190
  }
@@ -1,9 +1,11 @@
1
1
  <template>
2
2
  <div class="modal-card">
3
3
  <form @submit.prevent="register" method="post" action="/account/create" novalidate>
4
- <header v-if="showHeader" class="modal-card-head">
5
- <p class="modal-card-title">{{ title }} </p>
6
- <button @click="$emit('close')" type="button" class="modal-close is-large" style=""></button>
4
+ <header v-if="showHeader" class="modal-card-head is-flex">
5
+ <div class="modal-card-title">{{ title }} </div>
6
+ <div class="is-position-relative">
7
+ <button @click="$emit('close')" type="button" class="modal-close is-large" style=""></button>
8
+ </div>
7
9
  </header>
8
10
 
9
11
  <section class="modal-card-body">
@@ -15,9 +17,9 @@
15
17
  name="first_name"
16
18
  data-test="register-first-name"
17
19
  ref="first_name"
18
- @input="clearError('first_name')"
19
- @focus="clearError('first_name')"
20
20
  v-model="registrationData.first_name"
21
+ @focus="clearError('first_name')"
22
+ @update:model-value="clearError('first_name')"
21
23
  type="text"
22
24
  />
23
25
  </b-field>
@@ -28,9 +30,9 @@
28
30
  native-value="inside"
29
31
  name="last_name"
30
32
  data-test="register-last-name"
31
- @input="clearError('last_name')"
32
- @focus="clearError('last_name')"
33
33
  v-model="registrationData.last_name"
34
+ @focus="clearError('last_name')"
35
+ @update:model-value="clearError('last_name')"
34
36
  type="text"
35
37
  />
36
38
  </b-field>
@@ -38,11 +40,15 @@
38
40
  </div>
39
41
 
40
42
  <div v-if="parseInt(initialState.age_verification.enabled)">
41
- <dob-input @input="onDobInput" :error="errors.date_of_birth"></dob-input>
43
+ <dob-input
44
+ v-model="registrationData.date_of_birth"
45
+ :error="errors.date_of_birth"
46
+ @update:modelValue="onDobInput"
47
+ ></dob-input>
42
48
  </div>
43
49
 
44
50
  <b-field :label="$t('global.email')" label-position="inside" :type="{ 'is-danger': errors.email }" :message="errors.email">
45
- <b-input native-value="inside" name="email" data-test="register-email" @input="clearError('email')" @focus="clearError('email')" v-model="registrationData.email"></b-input>
51
+ <b-input native-value="inside" name="email" data-test="register-email" v-model="registrationData.email" @focus="clearError('email')" @update:model-value="clearError('email')"></b-input>
46
52
  </b-field>
47
53
 
48
54
  <b-field :label="$t('auth.password')" label-position="inside" :type="{ 'is-danger': errors.password }" :message="errors.password">
@@ -50,10 +56,10 @@
50
56
  native-value="inside"
51
57
  name="password"
52
58
  data-test="register-password"
53
- @input="clearError('password')"
59
+ v-model="registrationData.password"
54
60
  @focus="clearError('password')"
55
61
  type="password"
56
- v-model="registrationData.password"
62
+ @update:model-value="clearError('password')"
57
63
  :placeholder="$t('auth.passwordInfo')"
58
64
  />
59
65
  </b-field>
@@ -68,10 +74,10 @@
68
74
  native-value="inside"
69
75
  name="password_confirmation"
70
76
  data-test="register-password-confirm"
71
- @input="clearError('password_confirmation')"
77
+ v-model="registrationData.password_confirmation"
72
78
  @focus="clearError('password_confirmation')"
73
79
  type="password"
74
- v-model="registrationData.password_confirmation"
80
+ @update:model-value="clearError('password_confirmation')"
75
81
  />
76
82
  </b-field>
77
83
 
@@ -95,11 +101,14 @@
95
101
  </template>
96
102
 
97
103
  <script>
104
+ import { ref, onMounted } from 'vue'
105
+ import config from '../../config'
98
106
  import { request } from '../../api'
107
+ import { useBuefy, useInitialState, useMq, useT } from '../../composables/globals'
99
108
 
100
- import GoogleAnalyticsEEC from '../../utils/google-analytics-eec.js'
109
+ import GoogleAnalyticsEEC from '../../utils/google/google-analytics-eec.js'
101
110
 
102
- import DobInput from '../../components/DobInput'
111
+ import DobInput from '../../components/DobInput.vue'
103
112
 
104
113
  const registrationDataSchema = {
105
114
  scope: 'customer',
@@ -127,55 +136,56 @@ export default {
127
136
  },
128
137
  title: {
129
138
  type: String,
130
- default: function () {
131
- return this.$t('auth.createAnAccount', [this.initialState.site_name])
132
- }
139
+ default: 'Create an Account'
133
140
  }
134
141
  },
135
142
 
136
- data() {
137
- return {
138
- loading: false,
139
- errors: {},
140
- registrationData: { ...registrationDataSchema }
141
- }
142
- },
143
+ emits: ['close'],
144
+
145
+ setup(props, { emit }) {
146
+ const mq = useMq()
147
+ const { t: $t } = useT()
148
+ const $buefy = useBuefy()
149
+ const initialState = useInitialState()
150
+
151
+ // Reactive state
152
+ const loading = ref(false)
153
+ const errors = ref({})
154
+ const registrationData = ref({ ...registrationDataSchema })
155
+ const first_name = ref(null)
143
156
 
144
- methods: {
145
- onDobInput(e) {
146
- if (e) {
147
- this.errors.date_of_birth = ''
148
- console.log('onDobInput', e.toString())
157
+ // Methods
158
+ const onDobInput = (value) => {
159
+ if (value) {
160
+ errors.value.date_of_birth = ''
149
161
  }
150
- this.registrationData.date_of_birth = e.toString()
151
- },
162
+ }
152
163
 
153
- async register() {
154
- this.loading = true
164
+ const register = async () => {
165
+ loading.value = true
155
166
  try {
156
167
  let response = await request({
157
- baseURL: this.getConfig('BASE_URL'),
168
+ baseURL: config.BASE_URL,
158
169
  url: '/register',
159
170
  method: 'post',
160
- data: this.registrationData
171
+ data: registrationData.value
161
172
  })
162
- this.loading = false
173
+ loading.value = false
163
174
  let signupSource = 'standard'
164
- if(this.getSource) {
165
- signupSource = this.getSource()
175
+ if (props.getSource) {
176
+ signupSource = props.getSource()
166
177
  }
167
178
  GoogleAnalyticsEEC.signUp(signupSource)
168
- this.errors = {}
169
- //Object.assign(this.registrationData, this.$options.data().registrationData)
170
- this.registrationData = { ...registrationDataSchema }
171
- this.$buefy.dialog.alert({
172
- title: this.$t('auth.createAnAccount', ['']),
173
- message: '<div data-test="account-created-message">' + this.$t('auth.createAccountNotification') + '</div>',
179
+ errors.value = {}
180
+ registrationData.value = { ...registrationDataSchema }
181
+ $buefy.dialog.alert({
182
+ title: $t('auth.createAnAccount', ['']),
183
+ message: '<div data-test="account-created-message">' + $t('auth.createAccountNotification') + '</div>',
174
184
  confirmText: 'OK',
175
185
  type: 'is-primary',
176
186
  onConfirm: () => {
177
- if (this.redirectHandler) {
178
- this.redirectHandler()
187
+ if (props.redirectHandler) {
188
+ props.redirectHandler()
179
189
  } else {
180
190
  window.location.reload()
181
191
  }
@@ -183,16 +193,16 @@ export default {
183
193
  })
184
194
  } catch (error) {
185
195
  console.log('Error ', error)
186
- this.loading = false
196
+ loading.value = false
187
197
  if (error.errors !== undefined) {
188
- this.errors = error.errors
198
+ errors.value = error.errors
189
199
  } else {
190
200
  let msg = 'Something went wrong. Please try again later.'
191
- if(error.message) {
201
+ if (error.message) {
192
202
  msg = error.message
193
203
  }
194
- this.$buefy.dialog.alert({
195
- title: this.$t('auth.createAnAccount', ['']),
204
+ $buefy.dialog.alert({
205
+ title: $t('auth.createAnAccount', ['']),
196
206
  message: msg,
197
207
  confirmText: 'OK',
198
208
  type: 'is-danger'
@@ -200,18 +210,30 @@ export default {
200
210
  }
201
211
  }
202
212
  return false
203
- },
213
+ }
204
214
 
205
- clearError(field) {
206
- if (this.errors[field]) {
207
- this.errors[field] = ''
215
+ const clearError = (field) => {
216
+ if (errors.value[field]) {
217
+ errors.value[field] = ''
208
218
  }
209
219
  }
210
- },
211
220
 
212
- mounted() {
213
- if (this.$mq !== 'mobile') {
214
- this.$refs.first_name.focus()
221
+ // Lifecycle hooks
222
+ onMounted(() => {
223
+ if (mq.value !== 'mobile') {
224
+ first_name.value?.focus()
225
+ }
226
+ })
227
+
228
+ return {
229
+ loading,
230
+ errors,
231
+ registrationData,
232
+ first_name,
233
+ initialState,
234
+ onDobInput,
235
+ register,
236
+ clearError
215
237
  }
216
238
  }
217
239
  }
@@ -29,65 +29,80 @@
29
29
  </template>
30
30
 
31
31
  <script>
32
+ import { ref, onMounted } from 'vue'
33
+ import config from '../../config'
32
34
  import { request } from '../../api'
35
+ import { useBuefy, useT } from '../../composables/globals'
33
36
 
34
37
  export default {
35
38
  name: 'ResetPassword',
36
- data() {
37
- return {
38
- loading: false,
39
- email: '',
40
- errors: {}
41
- }
42
- },
39
+ emits: ['close'],
40
+ setup(props, { emit }) {
41
+ const $buefy = useBuefy()
42
+ const { t: $t } = useT()
43
43
 
44
- methods: {
45
- async resetPassword() {
46
- this.loading = true
44
+ // Reactive state
45
+ const loading = ref(false)
46
+ const email = ref('')
47
+ const errors = ref({})
48
+ const loginEmail = ref(null)
49
+
50
+ // Methods
51
+ const resetPassword = async () => {
52
+ loading.value = true
47
53
 
48
54
  try {
49
55
  let response = await request({
50
- baseURL: this.getConfig('BASE_URL'),
56
+ baseURL: config.BASE_URL,
51
57
  url: '/password/email',
52
58
  method: 'post',
53
- data: { email: this.email }
59
+ data: { email: email.value }
54
60
  })
55
- this.loading = false
56
- //console.log(response)
57
- this.$buefy.dialog.alert({
58
- title: this.$t('auth.resetPasswordSuccessTitle'),
61
+ loading.value = false
62
+
63
+ $buefy.dialog.alert({
64
+ title: $t('auth.resetPasswordSuccessTitle'),
59
65
  message: response.data.status,
60
66
  confirmText: 'OK',
61
- onConfirm: () => this.$emit('close')
67
+ onConfirm: () => emit('close')
62
68
  })
63
69
  } catch (error) {
64
- this.loading = false
65
- if(error.errors) {
66
- this.errors = error.errors
70
+ loading.value = false
71
+ if (error.errors) {
72
+ errors.value = error.errors
67
73
  } else {
68
74
  let msg = 'Something went wrong. Please try again later.'
69
- if(error.message) {
75
+ if (error.message) {
70
76
  msg = error.message
71
77
  }
72
- this.$buefy.dialog.alert({
73
- title: this.$t('auth.resetPassword'),
78
+ $buefy.dialog.alert({
79
+ title: $t('auth.resetPassword'),
74
80
  message: msg,
75
81
  confirmText: 'OK',
76
82
  type: 'is-danger'
77
83
  })
78
84
  }
79
85
  }
80
- },
86
+ }
81
87
 
82
- clearError(field) {
83
- if (this.errors[field]) {
84
- this.errors[field] = ''
88
+ const clearError = (field) => {
89
+ if (errors.value[field]) {
90
+ errors.value[field] = ''
85
91
  }
86
92
  }
87
- },
88
93
 
89
- mounted() {
90
- this.$refs.loginEmail.focus()
94
+ onMounted(() => {
95
+ loginEmail.value?.focus()
96
+ })
97
+
98
+ return {
99
+ loading,
100
+ email,
101
+ errors,
102
+ loginEmail,
103
+ resetPassword,
104
+ clearError
105
+ }
91
106
  }
92
107
  }
93
108
  </script>
@@ -53,7 +53,7 @@ export default {
53
53
  return false
54
54
  }
55
55
 
56
- const avloading = this.$buefy.loading.open()
56
+ const avloading = this.$buefy.loading.open({})
57
57
  try {
58
58
  let avresp = await Cart.ageVerification({
59
59
  date_of_birth: date_of_birth,
@@ -109,13 +109,13 @@ export default {
109
109
  return true
110
110
  },
111
111
  onclosed: function () {
112
- vm.$bus.$emit('ageCheckerVerified')
112
+ vm.$bus.emit('ageCheckerVerified')
113
113
  Cookie.set('ac_custom_verified', true)
114
114
  return true
115
115
  }
116
116
  }
117
117
 
118
- //const ac_script_loading = this.$buefy.loading.open()
118
+ //const ac_script_loading = this.$buefy.loading.open({})
119
119
 
120
120
  let agecheckerScript = document.createElement('script')
121
121
  agecheckerScript.setAttribute('id', 'age-checker-script')
@@ -39,6 +39,14 @@ export default {
39
39
  methods: {
40
40
  qtyClick() {
41
41
  window.location.href = '/shopping-cart'
42
+ },
43
+
44
+ onUpdateCart(cart) {
45
+ this.sumQty = cart.sumQty
46
+ },
47
+
48
+ onUpdateTotalQty(totalQty) {
49
+ this.sumQty = totalQty
42
50
  }
43
51
  },
44
52
 
@@ -48,10 +56,13 @@ export default {
48
56
  } else {
49
57
  this.sumQty = 0
50
58
  }
51
- this.$bus.$on('updateCart', (cart) => {
52
- this.sumQty = cart.sumQty
53
- })
54
- this.$bus.$on('updateTotalQty', (totalQty) => (this.sumQty = totalQty))
59
+ this.$bus.on('updateCart', this.onUpdateCart)
60
+ this.$bus.on('updateTotalQty', this.onUpdateTotalQty)
61
+ },
62
+
63
+ beforeUnmount() {
64
+ this.$bus.off('updateCart', this.onUpdateCart)
65
+ this.$bus.off('updateTotalQty', this.onUpdateTotalQty)
55
66
  }
56
67
  }
57
68
  </script>
@@ -77,14 +77,9 @@ export default {
77
77
 
78
78
  goToCart() {
79
79
  window.location.href = '/shopping-cart'
80
- }
81
- },
82
-
83
- mounted() {
80
+ },
84
81
 
85
- this.addToCartButton = document.querySelector('.add-to-cart')
86
-
87
- this.$bus.$on('addToCart', (product) => {
82
+ onAddToCart(product) {
88
83
  this.product = product
89
84
  this.isActive = true
90
85
 
@@ -116,16 +111,29 @@ export default {
116
111
  console.log('atcb', this.addToCartButton)
117
112
  if (this.addToCartButton) {
118
113
  this.addToCartButton.classList.add('is-hidden')
119
- }
114
+ }
120
115
  })
121
116
  }
122
- })
117
+ },
123
118
 
124
- this.$bus.$on('updateCart', (cart) => {
119
+ onUpdateCart(cart) {
125
120
  //console.log('received updateCart: ', cart)
126
121
  this.cartTotal = cart.subtotal
127
122
  this.sumQty = cart.sumQty
128
- })
123
+ }
124
+ },
125
+
126
+ mounted() {
127
+
128
+ this.addToCartButton = document.querySelector('.add-to-cart')
129
+
130
+ this.$bus.on('addToCart', this.onAddToCart)
131
+ this.$bus.on('updateCart', this.onUpdateCart)
132
+ },
133
+
134
+ beforeUnmount() {
135
+ this.$bus.off('addToCart', this.onAddToCart)
136
+ this.$bus.off('updateCart', this.onUpdateCart)
129
137
  }
130
138
  }
131
139
  </script>