浏览代码

Update profile to only show current user logged in

master
Lene Scholtz 5 年前
父节点
当前提交
41f1d9fd22

+ 44
- 16
src/components/user/updateProfileInfo.vue 查看文件

20
             <th>Telephone Number</th>
20
             <th>Telephone Number</th>
21
             <th>Email</th>
21
             <th>Email</th>
22
             <th>Role</th>
22
             <th>Role</th>
23
-            <th></th>
23
+            <th>Modify</th>
24
           </tr>
24
           </tr>
25
         </thead>
25
         </thead>
26
         <tbody>
26
         <tbody>
27
-          <tr v-for="(item, i) in individuals" :key="i">
28
-            <td>{{ item.id }}</td>
29
-            <td>{{ item.name }}</td>
30
-            <td>{{ item.surname }}</td>
31
-            <td>{{ item.cellNumber }}</td>
32
-            <td>{{ item.telephone }}</td>
33
-            <td>{{ item.email }}</td>
34
-            <td v-if="item.user">{{ item.user.role }}</td>
35
-            <td v-else></td>
27
+          <tr>
28
+            <td>{{ user.id }}</td>
29
+            <td>{{ indiv.name }}</td>
30
+            <td>{{ indiv.surname }}</td>
31
+            <td>{{ indiv.cellNumber }}</td>
32
+            <td>{{ indiv.landlineNumber }}</td>
33
+            <td>{{ indiv.emailAddress }}</td>
34
+            <td>{{ user.role }}</td>
36
             <td>
35
             <td>
37
               <button
36
               <button
38
                 type="button"
37
                 type="button"
63
 </template>
62
 </template>
64
 
63
 
65
 <script>
64
 <script>
66
-import { mapState, mapActions } from 'vuex';
65
+import { mapState, mapActions, mapGetters } from 'vuex';
67
 import Individual from './registerPage.vue';
66
 import Individual from './registerPage.vue';
68
 
67
 
69
 export default {
68
 export default {
71
   components: {
70
   components: {
72
     Individual,
71
     Individual,
73
   },
72
   },
73
+  props: {
74
+    currentUser: {
75
+      name: undefined,
76
+      surname: undefined,
77
+      idNumber: undefined,
78
+      companyRegNumber: undefined,
79
+      emailAddress: undefined,
80
+      cellNumber: undefined,
81
+      landlineNumer: undefined,
82
+      bankingDetails: {},
83
+      address: {},
84
+    },
85
+    showChangeCurrentUser: {
86
+      default: false,
87
+    },
88
+    showBank: {
89
+      default: false,
90
+    },
91
+    showAddress: {
92
+      default: false,
93
+    },
94
+  },
74
   data() {
95
   data() {
75
     return {
96
     return {
76
       item: {},
97
       item: {},
77
     };
98
     };
78
   },
99
   },
79
-  methods: {
80
-    ...mapActions('register', ['getIndividuals']),
81
-  },
82
   mounted() {
100
   mounted() {
83
-    this.getIndividuals();
101
+    if (!this.currentUser) {
102
+      if (this.user) {
103
+        this.getIndividual(this.user.id);
104
+      }
105
+    }
84
   },
106
   },
85
   computed: {
107
   computed: {
86
-    ...mapState('register', ['individuals']),
108
+    ...mapState('individual', ['indiv']),
109
+    ...mapGetters({
110
+      user: 'authentication/getUser',
111
+    }),
112
+  },
113
+  methods: {
114
+    ...mapActions('individual', ['getIndividual']),
87
   },
115
   },
88
 };
116
 };
89
 </script>
117
 </script>

+ 5
- 12
src/store/modules/user/authentication.js 查看文件

7
 export default {
7
 export default {
8
   namespaced: true,
8
   namespaced: true,
9
   state: {
9
   state: {
10
-    username: 'kobusb',
11
-    password: '123123',
10
+    username: 'UniVate2018',
11
+    password: 'UniVate2018',
12
     isLoggedIn: log.isLoggedIn(),
12
     isLoggedIn: log.isLoggedIn(),
13
     flag: false,
13
     flag: false,
14
     status: undefined,
14
     status: undefined,
55
     getUser: () => log.getUser(),
55
     getUser: () => log.getUser(),
56
   },
56
   },
57
   actions: {
57
   actions: {
58
-    init({
59
-      commit,
60
-    }) {
58
+    init({ commit }) {
61
       if (!log.isLoggedIn() && log.tokenExpired) {
59
       if (!log.isLoggedIn() && log.tokenExpired) {
62
         log.clearValues();
60
         log.clearValues();
63
       } else log.updateTokenExpiry();
61
       } else log.updateTokenExpiry();
68
         agency: log.getJSONObject('agency'),
66
         agency: log.getJSONObject('agency'),
69
       });
67
       });
70
     },
68
     },
71
-    login({
72
-      commit,
73
-      state,
74
-    }) {
69
+    login({ commit, state }) {
75
       axios({
70
       axios({
76
         url: '/api/register/authenticate',
71
         url: '/api/register/authenticate',
77
         data: {
72
         data: {
92
           commit('auth_error', err.data);
87
           commit('auth_error', err.data);
93
         });
88
         });
94
     },
89
     },
95
-    logout({
96
-      commit,
97
-    }) {
90
+    logout({ commit }) {
98
       return new Promise(() => {
91
       return new Promise(() => {
99
         commit('logout');
92
         commit('logout');
100
         log.clearValues();
93
         log.clearValues();

+ 5
- 6
src/store/modules/user/individual.js 查看文件

18
   },
18
   },
19
   getters: {},
19
   getters: {},
20
   actions: {
20
   actions: {
21
-    getIndividual({
22
-      commit,
23
-    }, userId) {
21
+    getIndividual({ commit }, userId) {
24
       axios
22
       axios
25
         .get(`/api/individual/getIndividual/${userId}`)
23
         .get(`/api/individual/getIndividual/${userId}`)
26
         .then(r => commit('setItem', {
24
         .then(r => commit('setItem', {
27
-          name: 'item',
28
-          value: r.data,
29
-        })).catch(console.error);
25
+            name: 'indiv',
26
+            value: r.data,
27
+          }),)
28
+        .catch(console.error);
30
     },
29
     },
31
   },
30
   },
32
 };
31
 };

正在加载...
取消
保存