PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.31
Booking for Appointments and Events Calendar – Amelia v1.2.31
2.4.9 2.4.8 2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / v3 / src / store / modules / customerInfo.js
ameliabooking / v3 / src / store / modules Last commit date
appointment.js 1 year ago attendee.js 1 year ago auth.js 1 year ago bookableType.js 3 years ago booking.js 1 year ago cabinet.js 2 years ago cabinetFilters.js 1 year ago coupon.js 2 years ago customFields.js 1 year ago customerInfo.js 1 year ago employee.js 1 year ago entities.js 1 year ago event.js 1 year ago eventBooking.js 3 years ago eventEntities.js 1 year ago eventWaitingListOptions.js 1 year ago pagination.js 3 years ago params.js 1 year ago payment.js 3 years ago persons.js 1 year ago recurring.js 1 year ago shortcodeParams.js 2 years ago tickets.js 1 year ago
customerInfo.js
308 lines
1 import httpClient from "../../plugins/axios";
2
3 export default {
4 namespaced: true,
5
6 state: () => ({
7 id: null,
8 externalId: '',
9 firstName: '',
10 lastName: '',
11 email: '',
12 phone: '',
13 countryPhoneIso: '',
14 loggedUser: false,
15 translations: '',
16 gender: '',
17 birthday: '',
18 note: '',
19 loading: false,
20 customers: [],
21 customersIds: [],
22 wpUsers: [],
23 customFields: null
24 }),
25
26 getters: {
27 getCustomerId (state) {
28 return state.id
29 },
30
31 getCustomerExternalId (state) {
32 return state.externalId
33 },
34
35 getCustomerFirstName (state) {
36 return state.firstName
37 },
38
39 getCustomerLastName (state) {
40 return state.lastName
41 },
42
43 getCustomerEmail (state) {
44 return state.email
45 },
46
47 getCustomerPhone (state) {
48 return state.phone
49 },
50
51 getCustomerCountryPhoneIso (state) {
52 return state.countryPhoneIso
53 },
54
55 getCustomerLanguage (state) {
56 return state.translations.defaultLanguage
57 },
58
59 getCustomerCustomFields (state) {
60 return state.customFields
61 },
62
63 getCustomerBirthday (state) {
64 return state.birthday
65 },
66
67 getCustomerGender (state) {
68 return state.gender
69 },
70
71 getCustomerNote (state) {
72 return state.note
73 },
74
75 getLoggedUser (state) {
76 return state.loggedUser
77 },
78
79 getAllData (state) {
80 return {
81 id: state.id,
82 externalId: state.externalId,
83 firstName: state.firstName,
84 lastName: state.lastName,
85 email: state.email,
86 phone: state.phone,
87 countryPhoneIso : state.countryPhoneIso,
88 loggedUser: state.loggedUser,
89 customFields: state.customFields
90 }
91 },
92
93 getLoading (state) {
94 return state.loading
95 },
96
97 getCustomers (state) {
98 return state.customers
99 },
100
101 getCustomersIds (state) {
102 return state.customersIds
103 },
104
105 getWpUsers (state) {
106 return state.wpUsers
107 },
108
109 getCustomer (state) {
110 return {
111 id: state.id,
112 externalId: state.externalId,
113 firstName: state.firstName,
114 lastName: state.lastName,
115 email: state.email,
116 phone: state.phone,
117 countryPhoneIso: state.countryPhoneIso,
118 translations: state.translations,
119 gender: state.gender,
120 birthday: state.birthday,
121 note: state.note,
122 customFields: state.customFields,
123 }
124 }
125 },
126
127 mutations: {
128 setCustomerId (state, payload) {
129 state.id = payload
130 },
131
132 setCustomerExternalId (state, payload) {
133 state.externalId = payload
134 },
135
136 setCustomerFirstName (state, payload) {
137 state.firstName = payload
138 },
139
140 setCustomerLastName (state, payload) {
141 state.lastName = payload
142 },
143
144 setCustomerEmail (state, payload) {
145 state.email = payload
146 },
147
148 setCustomerPhone (state, payload) {
149 state.phone = payload
150 },
151
152 setCustomerCountryPhoneIso (state, payload) {
153 state.countryPhoneIso = payload
154 },
155
156 setCustomerBirthday (state, payload) {
157 state.birthday = payload
158 },
159
160 setCustomerLanguage (state, payload) {
161 state.translations.defaultLanguage = payload
162 },
163
164 setCustomerGender (state, payload) {
165 state.gender = payload
166 },
167
168 setCustomerNote (state, payload) {
169 state.note = payload
170 },
171
172 setLoggedUser (state, payload) {
173 state.loggedUser = payload
174 },
175
176 setCurrentUser (state, payload) {
177 state.id = payload.id
178 state.externalid = payload.externalid
179 state.firstName = payload.firstName
180 state.lastName = payload.lastName
181 state.email = payload.email
182 state.phone = payload.phone || ''
183 state.countryPhoneIso = payload.countryPhoneIso || ''
184 state.customFields = payload.customFields || ''
185 },
186
187 setAllData (state, payload) {
188 state.id = payload.id
189 state.externalId = payload.externalId
190 state.firstName = payload.firstName
191 state.lastName = payload.lastName
192 state.email = payload.email
193 state.phone = payload.phone
194 state.countryPhoneIso = payload.countryPhoneIso
195 state.loggedUser = payload.loggedUser
196 state.customFields = payload.customFields
197 },
198
199 setCustomer (state, payload) {
200 state.id = payload.id
201 state.externalId = payload.externalId
202 state.firstName = payload.firstName
203 state.lastName = payload.lastName
204 state.email = payload.email
205 state.phone = payload.phone
206 state.countryPhoneIso = payload.countryPhoneIso
207 state.translations = payload.translations
208 state.gender = payload.gender
209 state.birthday = payload.birthday
210 state.note = payload.note
211 state.customFields = payload.customFields
212 },
213
214 setLoading (state, payload) {
215 state.loading = payload
216 },
217
218 setCustomers (state, payload) {
219 state.customers = payload
220 },
221
222 setCustomersIds (state, payload) {
223 state.customersIds = payload
224 },
225
226 setWpUsers (state, payload) {
227 state.wpUsers = payload
228 }
229 },
230
231 actions: {
232 requestCurrentUserData ({ commit }) {
233 commit('setLoading', true, {root: true})
234 if (!('ameliaUser' in window) || !window.ameliaUser) {
235 httpClient.get(
236 '/users/current'
237 ).then((response) => {
238 if (response.data.data.user) {
239 window.ameliaUser = response.data.data.user ? response.data.data.user : null
240
241 commit('setCurrentUser', window.ameliaUser)
242 commit('setLoggedUser', true)
243 }
244 commit('setLoading', false, {root: true})
245 }).catch(() => {
246 commit('setLoading', false, {root: true})
247 })
248 } else {
249 let ameliaApiInterval = setInterval(
250 () => {
251 if ('ameliaUser' in window) {
252 clearInterval(ameliaApiInterval)
253
254 commit('setCurrentUser', window.ameliaUser)
255 commit('setLoggedUser', true)
256 }
257 commit('setLoading', false, {root: true})
258 },
259 1000
260 )
261 }
262 },
263
264 requestWpUsers ({ commit, getters }, payload) {
265 let { label } = payload
266 commit('setLoading', true)
267 httpClient.get(
268 'users/wp-users',
269 {
270 params: {
271 id: getters['getCustomerId'],
272 role: 'customer'
273 }
274 }
275 ).then((response) => {
276 commit('setWpUsers', [{value: 0, label: label}, ...response.data.data.users])
277
278 if (getters['getWpUsers'].map(user => user.value).indexOf(getters['getCustomerExternalId']) === -1) {
279 commit('setCustomerExternalId', null)
280 }
281
282 commit('setLoading', false)
283 }).catch(() => {
284 commit('setLoading', false)
285 }).finally(() => {
286 commit('setLoading', false)
287 })
288 },
289
290 resetCustomer({commit}) {
291 commit('setCustomer', {
292 id: null,
293 externalId: '',
294 firstName: '',
295 lastName: '',
296 email: '',
297 phone: '',
298 countryPhoneIso: '',
299 translations: {defaultLanguage: ''},
300 gender: '',
301 birthday: '',
302 note: '',
303 customFields: null
304 })
305 }
306 }
307 }
308