@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,26 +1,23 @@
1
1
  <template>
2
-
3
-
4
- <div>
5
-
2
+ <div ref="container">
6
3
  <div>
7
- <strong>Total commissions:</strong> {{ summary.commission }} RSD
8
- </div>
4
+ <strong>Total commissions:</strong> {{ summary.commission }} RSD
5
+ </div>
9
6
  <div style="margin-bottom: 1rem;">
10
- <strong>Total sold:</strong> {{ summary.item }} RSD ({{summary.count}} items)
11
- </div>
7
+ <strong>Total sold:</strong> {{ summary.item }} RSD ({{ summary.count }} items)
8
+ </div>
12
9
 
13
- <b-table v-if="items.length > 0" :data="items" :hoverable="true" class="affiliate-report-table">
10
+ <b-table v-if="hasItems" :data="items" :hoverable="true" class="affiliate-report-table">
14
11
  <b-table-column v-slot="props" field="id" label="Order ID" width="75" numeric>
15
12
  {{ props.row.order_id }}
16
13
  </b-table-column>
17
14
 
18
15
  <b-table-column v-slot="props" field="date" label="Date" width="100">
19
- {{ new Date(props.row.order_created_at).toLocaleDateString() }}
16
+ {{ new Date(props.row.order_created_at).toLocaleDateString() }}
20
17
  </b-table-column>
21
18
 
22
- <b-table-column v-slot="props" field="iten" label="Item">
23
- {{ props.row.item_name }}
19
+ <b-table-column v-slot="props" field="item" label="Item">
20
+ {{ props.row.item_name }}
24
21
  </b-table-column>
25
22
 
26
23
  <b-table-column v-slot="props" field="price" label="Price" width="40" numeric>
@@ -42,61 +39,60 @@
42
39
  <b-table-column v-slot="props" field="commission" label="Commission" width="40" numeric>
43
40
  {{ props.row.commission_total }}
44
41
  </b-table-column>
45
-
46
42
  </b-table>
47
43
 
48
- <div v-if="items.length === 0">No items</div>
49
-
44
+ <div v-else>No items</div>
50
45
  </div>
51
46
  </template>
52
47
 
53
- <script>
54
-
55
- import { mapState, mapActions } from 'vuex'
56
-
57
- export default {
58
- name: 'AffiliateReport',
59
-
60
- data() {
61
- return {
62
- loading: false,
63
- items: [],
64
- summary: {
65
- item: 0,
66
- commission: 0,
67
- count: 0,
68
- }
69
- }
70
- },
71
- computed: {
72
- ...mapState(['affiliateReport'])
73
- },
74
- methods: {
75
-
76
- ...mapActions(['getAffiliateReport']),
77
-
78
- orderDetailClose() {
79
- this.selected = {}
80
- this.showOrderDetail = false
81
- },
82
-
83
- async init() {
84
- //this.loading = this.$buefy.loading.open()
85
- if(!this.afiliateReport) {
86
- const loading = this.$buefy.loading.open({
87
- container: this.$refs.container
88
- })
89
- await this.getAffiliateReport();
90
- loading.close()
91
- }
92
-
93
- this.items = this.affiliateReport.items
94
- this.summary = this.affiliateReport.total
48
+ <script setup>
49
+ import { computed, onMounted, ref } from 'vue'
50
+ import { useStore } from 'vuex'
51
+ import { useBuefy } from '../../composables/globals'
52
+
53
+ const store = useStore()
54
+ const buefy = useBuefy()
55
+ const container = ref(null)
56
+
57
+ const emptySummary = { item: 0, commission: 0, count: 0 }
58
+ const emptyReport = () => ({
59
+ items: [],
60
+ total: { ...emptySummary },
61
+ })
62
+
63
+ const affiliateReport = computed(() => {
64
+ const moduleReport = store.state?.account?.affiliateReport
65
+ const rootReport = store.state?.affiliateReport
66
+ return moduleReport || rootReport || emptyReport()
67
+ })
68
+
69
+ const items = computed(() => affiliateReport.value.items || [])
70
+ const summary = computed(() => affiliateReport.value.total || emptySummary)
71
+ const hasItems = computed(() => items.value.length > 0)
72
+
73
+ const fetchAffiliateReport = async () => {
74
+ let loadingInstance
75
+
76
+ try {
77
+ if (buefy?.loading?.open) {
78
+ loadingInstance = buefy.loading.open({
79
+ container: container.value || undefined,
80
+ })
95
81
  }
96
- },
97
82
 
98
- mounted() {
99
- this.init()
83
+ await store.dispatch('getAffiliateReport')
84
+ } catch (error) {
85
+ console.error('Failed to load affiliate report', error)
86
+ } finally {
87
+ if (loadingInstance?.close) {
88
+ loadingInstance.close()
89
+ }
100
90
  }
101
91
  }
92
+
93
+ onMounted(() => {
94
+ if (!hasItems.value) {
95
+ fetchAffiliateReport()
96
+ }
97
+ })
102
98
  </script>
@@ -68,12 +68,12 @@
68
68
  </tr>
69
69
  </thead>
70
70
  <tbody>
71
- <tr v-for="item in order.items">
71
+ <tr v-for="item in order.items" :key="item.id">
72
72
  <td>{{ item.name }}</td>
73
73
  <td class="has-text-right">{{ item.qty }}</td>
74
- <td class="has-text-right">{{ item.price | formatMoney }}</td>
74
+ <td class="has-text-right">{{ formatMoney(item.price) }}</td>
75
75
  <td class="has-text-right">
76
- {{ (parseInt(item.qty) * parseFloat(item.price)) | formatMoney }}
76
+ {{ formatMoney(parseInt(item.qty) * parseFloat(item.price)) }}
77
77
  </td>
78
78
  </tr>
79
79
  <tr>
@@ -81,7 +81,7 @@
81
81
  <strong>{{ $t('global.subtotal') }}</strong>
82
82
  </td>
83
83
  <td class="has-text-right">
84
- {{ order.subtotal | formatMoney }}
84
+ {{ formatMoney(order.subtotal) }}
85
85
  </td>
86
86
  </tr>
87
87
  <tr>
@@ -89,7 +89,7 @@
89
89
  <strong>{{ $t('global.shipping') }}</strong>
90
90
  </td>
91
91
  <td class="has-text-right">
92
- {{ order.shipping | formatMoney }}
92
+ {{ formatMoney(order.shipping) }}
93
93
  </td>
94
94
  </tr>
95
95
  <tr>
@@ -97,7 +97,7 @@
97
97
  <strong>{{ $t('global.tax') }}</strong>
98
98
  </td>
99
99
  <td class="has-text-right">
100
- {{ order.taxAmount | formatMoney }}
100
+ {{ formatMoney(order.taxAmount) }}
101
101
  </td>
102
102
  </tr>
103
103
  <tr v-if="parseFloat(order.discount) > 0">
@@ -105,7 +105,7 @@
105
105
  <strong>{{ $t('global.discount') }}</strong>
106
106
  </td>
107
107
  <td class="has-text-right">
108
- {{ order.discount | formatMoney }}
108
+ {{ formatMoney(order.discount) }}
109
109
  </td>
110
110
  </tr>
111
111
  <tr>
@@ -113,7 +113,7 @@
113
113
  <strong>{{ $t('global.total') }}</strong>
114
114
  </td>
115
115
  <td class="has-text-right">
116
- {{ order.total | formatMoney($LC.currencySymbol) }}
116
+ {{ formatMoney(order.total) }}
117
117
  </td>
118
118
  </tr>
119
119
  </tbody>
@@ -124,32 +124,46 @@
124
124
  </div>
125
125
  </template>
126
126
 
127
- <script>
128
- import { Order } from '../../api'
127
+ <script setup>
128
+ import { ref, onBeforeMount } from 'vue'
129
+ import { useBuefy } from '../../../composables/globals'
130
+ import Order from '../../../api/order'
131
+ import { formatMoney } from '../../../utils/filters'
129
132
 
130
- export default {
131
- name: 'OrderDetail',
132
-
133
- props: {
134
- head: Object,
135
- id: Number,
136
- title: String
133
+ const props = defineProps({
134
+ head: {
135
+ type: Object,
136
+ required: false
137
137
  },
138
-
139
- data() {
140
- return {
141
- order: {}
142
- }
138
+ id: {
139
+ type: Number,
140
+ required: true
143
141
  },
142
+ title: {
143
+ type: String,
144
+ required: false
145
+ }
146
+ })
144
147
 
145
- beforeMount() {
146
- let orderDetailLoading = this.$buefy.loading.open()
147
- Order.get(this.id).then((response) => {
148
- this.order = response.data.data
149
- orderDetailLoading.close()
150
- })
151
- },
148
+ const order = ref({})
149
+ const buefy = useBuefy()
152
150
 
153
- mounted() {}
151
+ // Fetch order details on component mount
152
+ const loadOrderDetail = () => {
153
+ const orderDetailLoading = buefy.loading.open({})
154
+
155
+ Order.get(props.id)
156
+ .then((response) => {
157
+ order.value = response.data.data
158
+ orderDetailLoading?.close?.()
159
+ })
160
+ .catch((error) => {
161
+ console.error('Error loading order detail:', error)
162
+ orderDetailLoading?.close?.()
163
+ })
154
164
  }
165
+
166
+ onBeforeMount(() => {
167
+ loadOrderDetail()
168
+ })
155
169
  </script>
@@ -0,0 +1,124 @@
1
+ <template>
2
+ <div>
3
+ <b-table v-if="!showOrderDetail && orders.length !== 0" :data="orders" v-model:selected="selected" :hoverable="true" @select="select" class="orders-table">
4
+ <b-table-column v-slot="props" field="id" label="ID" width="40" numeric sortable>
5
+ {{ props.row.id }}
6
+ </b-table-column>
7
+
8
+ <b-table-column v-slot="props" field="date" label="Date" width="60" sortable>
9
+ <span class="tag">
10
+ {{ new Date(props.row.date).toLocaleDateString() }}
11
+ </span>
12
+ </b-table-column>
13
+
14
+ <b-table-column v-slot="props" field="total" label="Total" width="200" numeric sortable>
15
+ {{ props.row.total }}
16
+ </b-table-column>
17
+
18
+ <b-table-column v-slot="props" field="order_status.name" label="Status">
19
+ {{ props.row.order_status.name }}
20
+ </b-table-column>
21
+ </b-table>
22
+
23
+ <div v-if="!orders.length">{{ noOrdersNotification }}</div>
24
+
25
+ <div v-if="showOrderDetail">
26
+ <OrderDetail :title="$t('global.order') + ' #' + selected.id" :id="selected.id"></OrderDetail>
27
+ </div>
28
+ </div>
29
+ </template>
30
+
31
+ <script setup>
32
+ import { ref, onMounted } from 'vue'
33
+ import { Order } from '../../../api'
34
+ import { useBuefy, useBus, useInitialState, useT } from '../../../composables/globals'
35
+ import OrderDetail from './OrderDetail.vue'
36
+
37
+ defineProps({
38
+ noOrdersNotification: {
39
+ type: String,
40
+ default: () => {
41
+ // Props defaults can't translate; AccountDashboard passes a translated text
42
+ return 'No orders found'
43
+ }
44
+ }
45
+ })
46
+
47
+ const selected = ref({})
48
+ const orders = ref([])
49
+ const showOrderDetail = ref(false)
50
+ const loadingOrders = ref(null)
51
+ const buefy = useBuefy()
52
+ const eventBus = useBus()
53
+ const initialState = useInitialState()
54
+ const { t } = useT()
55
+
56
+ // Fetch orders from API
57
+ const getOrders = () => {
58
+ Order.getList()
59
+ .then((response) => {
60
+ orders.value = response.data.data
61
+ if (loadingOrders.value) {
62
+ loadingOrders.value.close()
63
+ }
64
+ })
65
+ .catch((error) => {
66
+ console.log('Order loading error', error)
67
+ if (loadingOrders.value) {
68
+ loadingOrders.value.close()
69
+ }
70
+ })
71
+ }
72
+
73
+ // Handle row selection
74
+ const select = (row) => {
75
+ showOrderDetail.value = true
76
+ const ordersText = t('account.orders')
77
+ const globalOrderText = t('global.order')
78
+ const siteName = initialState.site_name || 'Supermarket'
79
+
80
+ history.pushState(
81
+ null,
82
+ `${siteName} ${ordersText} > ${globalOrderText} #${row.id}`,
83
+ `/account?tab=orders&id=${row.id}`
84
+ )
85
+ }
86
+
87
+ // Handle order detail close
88
+ const orderDetailClose = () => {
89
+ selected.value = {}
90
+ showOrderDetail.value = false
91
+ }
92
+
93
+ // Initialize component
94
+ const init = () => {
95
+ if (buefy?.loading?.open) {
96
+ loadingOrders.value = buefy.loading.open({})
97
+ }
98
+
99
+ const urlOrderId = parseInt(new URL(document.location).searchParams.get('id'))
100
+ if (urlOrderId) {
101
+ selected.value = { id: urlOrderId }
102
+ showOrderDetail.value = true
103
+ if (orders.value.length === 0) {
104
+ getOrders()
105
+ }
106
+ } else {
107
+ getOrders()
108
+ }
109
+ }
110
+
111
+ // Component lifecycle
112
+ onMounted(() => {
113
+ init()
114
+
115
+ // Listen for order detail close events from event bus
116
+ eventBus.on('orderDetailClose', orderDetailClose)
117
+
118
+ // Handle browser back button
119
+ window.addEventListener('popstate', () => {
120
+ console.log('popstate orders', window.location.href)
121
+ showOrderDetail.value = false
122
+ })
123
+ })
124
+ </script>
@@ -11,11 +11,11 @@
11
11
  </template>
12
12
 
13
13
  <script>
14
- import { User } from '../../api'
14
+ import { User } from '../../../api'
15
15
 
16
- import ChangeEmail from './ChangeEmail'
17
- import ChangePassword from './ChangePassword'
18
- import ChangeName from './ChangeName'
16
+ import ChangeEmail from './ChangeEmail.vue'
17
+ import ChangePassword from './ChangePassword.vue'
18
+ import ChangeName from './ChangeName.vue'
19
19
 
20
20
  export default {
21
21
  name: 'AccountUpdate',
@@ -0,0 +1,136 @@
1
+ <template>
2
+ <div class="email-wrapper column-wrapper">
3
+ <div class="email-header">
4
+ <p>{{ $t('global.email') }}</p>
5
+ </div>
6
+ <div class="columns is-gapless email">
7
+ <div class="column is-one-third">
8
+ <div class="current-email">
9
+ <p>{{ $t('account.currentEmail') }}</p>
10
+ <p class="email-address">{{ userData.email }}</p>
11
+ </div>
12
+ <div class="email-status">
13
+ <p class="status">{{ $t('global.status') }}</p>
14
+ <p class="confirmed" v-if="userData.email_confirmed">{{ $t('global.confirmed') }}</p>
15
+ <p class="not-confirmed" v-if="!userData.email_confirmed">{{ $t('global.unconfirmed') }}</p>
16
+ <div v-if="!userData.email_confirmed">
17
+ <button @click="resendConfirmation" :class="['button', {'is-loading': resendLoading}]" type="button">{{ $t('account.resendConfirmation') }}</button>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ </div>
22
+ <div class="columns-wrapper">
23
+ <div class="columns is-gapless">
24
+ <div class="column is-one-third">
25
+ <p class="email-headline">{{ $t('account.changeEmailTitle') }}</p>
26
+
27
+ <b-field
28
+ :label="$t('account.lYourPassword')"
29
+ label-position="inside"
30
+ :type="{ 'is-danger': errors.current_password }"
31
+ :message="errors.current_password"
32
+ >
33
+ <b-input native-value="inside" type="password" v-model="userData.current_password" @update:model-value="clearError('current_password')"></b-input>
34
+ </b-field>
35
+
36
+ <b-field :label="$t('account.lNewEmail')" label-position="inside" :type="{ 'is-danger': errors.email }" :message="errors.email">
37
+ <b-input native-value="inside" v-model="userData.email" @update:model-value="clearError('email')"></b-input>
38
+ </b-field>
39
+
40
+ <b-field :label="$t('account.lConfirmNewEmail')" label-position="inside" :type="{ 'is-danger': errors.email }" :message="errors.email">
41
+ <b-input native-value="inside" label-position="inside" v-model="userData.email_confirmation" @update:model-value="clearError('email')"></b-input>
42
+ </b-field>
43
+ </div>
44
+
45
+ <div class="column"></div>
46
+ </div>
47
+
48
+ <button type="button" @click="warningMessage" class="button is-primary change-email">{{ $t('account.changeEmail') }}</button>
49
+ </div>
50
+ </div>
51
+ </template>
52
+
53
+ <script setup>
54
+ import { ref } from 'vue'
55
+ import { useBuefy, useT } from '../../../composables/globals'
56
+ import config from '../../../config'
57
+ import { request, User } from '../../../api'
58
+
59
+ const props = defineProps({
60
+ userData: {
61
+ type: Object,
62
+ required: true
63
+ }
64
+ })
65
+
66
+ // Get global properties
67
+ const { t } = useT()
68
+ const buefy = useBuefy()
69
+
70
+ // Reactive state
71
+ const errors = ref({})
72
+ const resendLoading = ref(false)
73
+
74
+ // Methods
75
+ const submit = () => {
76
+ User.updateEmail(props.userData)
77
+ .then((response) => {
78
+ if (response.status === 200 || response.status === 201) {
79
+ buefy?.toast.open({
80
+ message: t('account.emailUpdatedNotification'),
81
+ type: 'is-success'
82
+ })
83
+ } else {
84
+ buefy?.dialog.alert({
85
+ title: t('account.emailUpdateDialogTitle'),
86
+ message: t('account.emailUpdateErrorNotification'),
87
+ confirmText: 'OK',
88
+ type: 'is-info'
89
+ })
90
+ }
91
+ })
92
+ .catch((error) => {
93
+ if (error.errors !== undefined) {
94
+ errors.value = error.errors
95
+ }
96
+ })
97
+ }
98
+
99
+ const resendConfirmation = async () => {
100
+ resendLoading.value = true
101
+ try {
102
+ await request({
103
+ baseURL: config.BASE_URL,
104
+ url: '/account/resend-verification',
105
+ method: 'post',
106
+ data: {}
107
+ })
108
+ buefy?.dialog.alert({
109
+ title: 'Success',
110
+ message: 'Check your email for confirmation link.',
111
+ confirmText: 'OK',
112
+ type: 'is-info'
113
+ })
114
+ } finally {
115
+ resendLoading.value = false
116
+ }
117
+ }
118
+
119
+ const clearError = (field) => {
120
+ if (errors.value[field]) {
121
+ errors.value[field] = ''
122
+ }
123
+ }
124
+
125
+ const warningMessage = () => {
126
+ buefy?.dialog.confirm({
127
+ title: t('account.emailUpdateDialogTitle'),
128
+ message: t('account.emailUpdateConfirm'),
129
+ confirmText: 'Ok',
130
+ type: 'is-success',
131
+ onConfirm: () => {
132
+ submit()
133
+ }
134
+ })
135
+ }
136
+ </script>
@@ -0,0 +1,82 @@
1
+ <template>
2
+ <div class="name-wrapper">
3
+ <div class="name-header">
4
+ <p>{{ $t('account.memberSince') }}</p>
5
+ <p>{{ userData.member_since }}</p>
6
+ </div>
7
+
8
+ <div class="columns is-gapless">
9
+ <div class="column is-one-third">
10
+ <b-field :label="$t('address.firstName')" label-position="inside" :type="{ 'is-danger': errors.first_name }" :message="errors.first_name">
11
+ <b-input native-value="inside" v-model="userData.first_name" @update:model-value="clearError('first_name')"></b-input>
12
+ </b-field>
13
+
14
+ <b-field :label="$t('address.lastName')" label-position="inside" :type="{ 'is-danger': errors.last_name }" :message="errors.last_name">
15
+ <b-input native-value="inside" v-model="userData.last_name" @update:model-value="clearError('last_name')"></b-input>
16
+ </b-field>
17
+
18
+ <dob-input
19
+ v-if="parseInt(initialState.age_verification.enabled)"
20
+ v-model="userData.date_of_birth"
21
+ :error="errors.date_of_birth"
22
+ />
23
+ </div>
24
+ </div>
25
+
26
+ <button type="button" @click="warningMessage" class="button is-primary change-name">{{ $t('global.save') }}</button>
27
+ </div>
28
+ </template>
29
+
30
+ <script setup>
31
+ import { ref } from 'vue'
32
+ import { useBuefy, useInitialState, useT } from '../../../composables/globals'
33
+ import { User } from '../../../api'
34
+ import DobInput from '../../../components/DobInput.vue'
35
+
36
+ const props = defineProps({
37
+ userData: Object
38
+ })
39
+
40
+ const { t: $t } = useT()
41
+ const $buefy = useBuefy()
42
+ const initialState = useInitialState()
43
+
44
+ const errors = ref({})
45
+
46
+ const submit = () => {
47
+ User.updateName(props.userData)
48
+ .then(() => {
49
+ $buefy.toast.open({
50
+ message: $t('account.savedNotification'),
51
+ type: 'is-success'
52
+ })
53
+ })
54
+ .catch((error) => {
55
+ if (error.errors !== undefined) {
56
+ errors.value = error.errors
57
+ }
58
+ })
59
+
60
+ User.updateDateOfBirth(props.userData).catch((error) => {
61
+ errors.value = error.errors
62
+ })
63
+ }
64
+
65
+ const clearError = (field) => {
66
+ if (errors.value[field]) {
67
+ errors.value[field] = ''
68
+ }
69
+ }
70
+
71
+ const warningMessage = () => {
72
+ $buefy.dialog.confirm({
73
+ title: $t('account.dialogTitle'),
74
+ message: $t('account.confirm'),
75
+ confirmText: 'Ok',
76
+ type: 'is-info',
77
+ onConfirm: () => {
78
+ submit()
79
+ }
80
+ })
81
+ }
82
+ </script>