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