appointment.js
2 days ago
appointmentWaitingListOptions.js
2 days ago
attendee.js
2 days ago
auth.js
2 days ago
bookableType.js
2 days ago
booking.js
2 days ago
cabinet.js
2 days ago
cabinetFilters.js
2 days ago
coupon.js
2 days ago
customFields.js
2 days ago
customerInfo.js
2 days ago
employee.js
2 days ago
entities.js
2 days ago
event.js
2 days ago
eventBooking.js
2 days ago
eventEntities.js
2 days ago
eventWaitingListOptions.js
2 days ago
pagination.js
2 days ago
params.js
2 days ago
payment.js
2 days ago
persons.js
2 days ago
recurring.js
2 days ago
shortcodeParams.js
2 days ago
stepByStepFilters.js
2 days ago
tickets.js
2 days ago
auth.js
288 lines
| 1 | import moment from 'moment' |
| 2 | import httpClient from '../../plugins/axios' |
| 3 | |
| 4 | export default { |
| 5 | namespaced: true, |
| 6 | |
| 7 | state: () => ({ |
| 8 | email: '', |
| 9 | password: '', |
| 10 | newPassword: '', |
| 11 | confirmPassword: '', |
| 12 | authenticated: false, |
| 13 | profile: null, |
| 14 | profileDeleted: false, |
| 15 | loggedOut: false, |
| 16 | googleLoading: false, |
| 17 | outlookLoading: false, |
| 18 | appleLoading: false, |
| 19 | stripeLoading: false, |
| 20 | zoomLoading: false, |
| 21 | spacesLoading: false, |
| 22 | zoomUsers: [], |
| 23 | googleCalendars: [], |
| 24 | outlookCalendars: [], |
| 25 | appleCalendars: [], |
| 26 | stripeProvider: { |
| 27 | id: '', |
| 28 | type: '', |
| 29 | email: '', |
| 30 | completed: false, |
| 31 | }, |
| 32 | spaces: [], |
| 33 | loadingAppointmentsCounter: 0, |
| 34 | loadingEventsCounter: 0, |
| 35 | preloaded: { |
| 36 | customers: [], |
| 37 | events: [], |
| 38 | }, |
| 39 | }), |
| 40 | |
| 41 | getters: { |
| 42 | getEmail(state) { |
| 43 | return state.email |
| 44 | }, |
| 45 | |
| 46 | getPassword(state) { |
| 47 | return state.password |
| 48 | }, |
| 49 | |
| 50 | getNewPassword(state) { |
| 51 | return state.newPassword |
| 52 | }, |
| 53 | |
| 54 | getConfirmPassword(state) { |
| 55 | return state.confirmPassword |
| 56 | }, |
| 57 | |
| 58 | getAuthenticated(state) { |
| 59 | return state.authenticated |
| 60 | }, |
| 61 | |
| 62 | getProfile(state) { |
| 63 | return state.profile |
| 64 | }, |
| 65 | |
| 66 | getProfileDeleted(state) { |
| 67 | return state.profileDeleted |
| 68 | }, |
| 69 | |
| 70 | getLoggedOut(state) { |
| 71 | return state.loggedOut |
| 72 | }, |
| 73 | |
| 74 | getGoogleLoading(state) { |
| 75 | return state.googleLoading |
| 76 | }, |
| 77 | |
| 78 | getOutlookLoading(state) { |
| 79 | return state.outlookLoading |
| 80 | }, |
| 81 | |
| 82 | getAppleLoading(state) { |
| 83 | return state.appleLoading |
| 84 | }, |
| 85 | |
| 86 | getStripeLoading(state) { |
| 87 | return state.stripeLoading |
| 88 | }, |
| 89 | |
| 90 | getZoomLoading(state) { |
| 91 | return state.zoomLoading |
| 92 | }, |
| 93 | |
| 94 | getSpacesLoading(state) { |
| 95 | return state.spacesLoading |
| 96 | }, |
| 97 | |
| 98 | getZoomUsers(state) { |
| 99 | return state.zoomUsers |
| 100 | }, |
| 101 | |
| 102 | getSpaces(state) { |
| 103 | return state.spaces |
| 104 | }, |
| 105 | |
| 106 | getGoogleCalendars(state) { |
| 107 | return state.googleCalendars |
| 108 | }, |
| 109 | |
| 110 | getOutlookCalendars(state) { |
| 111 | return state.outlookCalendars |
| 112 | }, |
| 113 | |
| 114 | getAppleCalendars(state) { |
| 115 | return state.appleCalendars |
| 116 | }, |
| 117 | |
| 118 | getStripeProvider(state) { |
| 119 | return state.stripeProvider |
| 120 | }, |
| 121 | |
| 122 | getLoadingAppointmentsCounter(state) { |
| 123 | return state.loadingAppointmentsCounter |
| 124 | }, |
| 125 | |
| 126 | getLoadingEventsCounter(state) { |
| 127 | return state.loadingEventsCounter |
| 128 | }, |
| 129 | |
| 130 | getPreloadedEvents(state) { |
| 131 | return state.preloaded.events |
| 132 | }, |
| 133 | |
| 134 | getPreloadedCustomers(state) { |
| 135 | return state.preloaded.customers |
| 136 | }, |
| 137 | }, |
| 138 | |
| 139 | mutations: { |
| 140 | setEmail(state, payload) { |
| 141 | state.email = payload |
| 142 | }, |
| 143 | |
| 144 | setPassword(state, payload) { |
| 145 | state.password = payload |
| 146 | }, |
| 147 | |
| 148 | setNewPassword(state, payload) { |
| 149 | state.newPassword = payload |
| 150 | }, |
| 151 | |
| 152 | setConfirmPassword(state, payload) { |
| 153 | state.confirmPassword = payload |
| 154 | }, |
| 155 | |
| 156 | setAuthenticated(state, payload) { |
| 157 | state.authenticated = payload |
| 158 | }, |
| 159 | |
| 160 | setProfile(state, payload) { |
| 161 | state.profile = payload |
| 162 | |
| 163 | if (state.profile.phone === null) { |
| 164 | state.profile.phone = '' |
| 165 | } |
| 166 | |
| 167 | if (state.profile.birthday) { |
| 168 | state.profile.birthday = moment(payload.birthday.date).format('YYYY-MM-DD') |
| 169 | } |
| 170 | }, |
| 171 | |
| 172 | setProfileFirstName(state, payload) { |
| 173 | state.profile.firstName = payload |
| 174 | }, |
| 175 | |
| 176 | setProfileLastName(state, payload) { |
| 177 | state.profile.lastName = payload |
| 178 | }, |
| 179 | |
| 180 | setProfileEmail(state, payload) { |
| 181 | state.profile.email = payload |
| 182 | }, |
| 183 | |
| 184 | setProfilePhone(state, payload) { |
| 185 | state.profile.phone = payload |
| 186 | }, |
| 187 | |
| 188 | setProfileCountryPhoneIso(state, payload) { |
| 189 | state.profile.countryPhoneIso = payload |
| 190 | }, |
| 191 | |
| 192 | setProfileBirthday(state, payload) { |
| 193 | state.profile.birthday = payload |
| 194 | }, |
| 195 | |
| 196 | setProfileDeleted(state, payload) { |
| 197 | state.profileDeleted = payload |
| 198 | }, |
| 199 | |
| 200 | setLoggedOut(state, payload) { |
| 201 | state.loggedOut = payload |
| 202 | }, |
| 203 | |
| 204 | setGoogleLoading(state, payload) { |
| 205 | state.googleLoading = payload |
| 206 | }, |
| 207 | |
| 208 | setOutlookLoading(state, payload) { |
| 209 | state.outlookLoading = payload |
| 210 | }, |
| 211 | |
| 212 | setAppleLoading(state, payload) { |
| 213 | state.appleLoading = payload |
| 214 | }, |
| 215 | |
| 216 | setStripeLoading(state, payload) { |
| 217 | state.stripeLoading = payload |
| 218 | }, |
| 219 | |
| 220 | setZoomLoading(state, payload) { |
| 221 | state.zoomLoading = payload |
| 222 | }, |
| 223 | |
| 224 | setSpacesLoading(state, payload) { |
| 225 | state.spacesLoading = payload |
| 226 | }, |
| 227 | |
| 228 | setZoomUsers(state, payload) { |
| 229 | state.zoomUsers = payload |
| 230 | }, |
| 231 | |
| 232 | setSpaces(state, payload) { |
| 233 | state.spaces = payload |
| 234 | }, |
| 235 | |
| 236 | setGoogleCalendars(state, payload) { |
| 237 | state.googleCalendars = payload |
| 238 | }, |
| 239 | |
| 240 | setOutlookCalendars(state, payload) { |
| 241 | state.outlookCalendars = payload |
| 242 | }, |
| 243 | |
| 244 | setAppleCalendars(state, payload) { |
| 245 | state.appleCalendars = payload |
| 246 | }, |
| 247 | |
| 248 | setStripeProvider(state, payload) { |
| 249 | state.stripeProvider = payload |
| 250 | }, |
| 251 | |
| 252 | setLoadingAppointmentsCounter(state, payload) { |
| 253 | state.loadingAppointmentsCounter = payload |
| 254 | }, |
| 255 | |
| 256 | setLoadingEventsCounter(state, payload) { |
| 257 | state.loadingEventsCounter = payload |
| 258 | }, |
| 259 | |
| 260 | setPreloadedEvents(state, payload) { |
| 261 | state.preloaded.events = payload |
| 262 | }, |
| 263 | |
| 264 | setPreloadedCustomers(state, payload) { |
| 265 | state.preloaded.customers = payload |
| 266 | }, |
| 267 | }, |
| 268 | |
| 269 | actions: { |
| 270 | logout({ commit }) { |
| 271 | commit('setPassword', '') |
| 272 | commit('setAuthenticated', false) |
| 273 | commit('setLoggedOut', true) |
| 274 | localStorage.removeItem('vue-authenticate.vueauth_token') |
| 275 | |
| 276 | try { |
| 277 | httpClient.post('/users/logout', {}, {}) |
| 278 | |
| 279 | if (window?.ameliaBooking?.cabinet?.userLoggedOut) { |
| 280 | window.ameliaBooking.cabinet.userLoggedOut() |
| 281 | } |
| 282 | } catch (error) { |
| 283 | console.log(error) |
| 284 | } |
| 285 | }, |
| 286 | }, |
| 287 | } |
| 288 |