-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathuser.js
More file actions
49 lines (44 loc) · 837 Bytes
/
user.js
File metadata and controls
49 lines (44 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* eslint-disable no-shadow */
const state = {
user: null,
};
const getters = {
getLoggedInUser(state) {
return state.user;
},
};
const mutations = {
login(state, user) {
for (let i = 0; i < user.images.length; i += 1) {
if (user.images[i].is_primary) {
const primaryCopy = user.images[i];
user.images.splice(i, 1);
user.images.unshift(primaryCopy);
}
}
state.user = user;
},
logout(state) {
state.user = null;
},
profileCompleted(state) {
state.user.is_profile_completed = true;
},
};
const actions = {
login(state, user) {
state.commit('login', user);
},
logout(state) {
state.commit('logout');
},
profileCompleted(state) {
state.commit('profileCompleted');
},
};
export default {
state,
getters,
mutations,
actions,
};