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