Bladeren bron

Registration from Front End

master
LeneS 5 jaren geleden
bovenliggende
commit
fafc9a39ca

+ 8
- 0
src/components/user/loginPage.vue Bestand weergeven

@@ -108,6 +108,14 @@ export default {
108 108
       this.showPassword = false;
109 109
       this.isPasswordShown = 'password';
110 110
     },
111
+    // authHeader() {
112
+    //   const user = JSON.parse(localStorage.getItem('user'));
113
+
114
+    //   if (user && user.token) {
115
+    //     return { Authoriztion: `Bearer ${user.token}` };
116
+    //   }
117
+    //   return {};
118
+    // },
111 119
   },
112 120
 };
113 121
 </script>

+ 67
- 18
src/components/user/registerAgencySection.vue Bestand weergeven

@@ -7,7 +7,13 @@
7 7
           <h4>Agency Details</h4>
8 8
           <div class="col-md-8" style="margin-bottom: 1em">
9 9
             <eva-icon name="people" fill="#60CBEB"></eva-icon>
10
-            <input class="form-control" type="text" name="agencyname" placeholder="Agency Name" />
10
+            <input
11
+              class="form-control"
12
+              type="text"
13
+              name="agencyname"
14
+              placeholder="Agency Name"
15
+              v-model="registerAgency.name"
16
+            />
11 17
           </div>
12 18
           <div class="col-md-8" style="margin-bottom: 1em">
13 19
             <eva-icon name="book" fill="#60CBEB"></eva-icon>
@@ -16,6 +22,7 @@
16 22
               type="text"
17 23
               name="eaabffcnumber"
18 24
               placeholder="EAAB FFC Number"
25
+              v-model="registerAgency.eaabeffcNumber"
19 26
             />
20 27
           </div>
21 28
           <div class="col-md-8">
@@ -25,6 +32,7 @@
25 32
               type="text"
26 33
               name="companyregnumber"
27 34
               placeholder="Company Registration Number"
35
+              v-model="registerAgency.companyRegNumber"
28 36
             />
29 37
           </div>
30 38
           <hr />
@@ -33,18 +41,36 @@
33 41
             <div class="row" style="text-align:left">
34 42
               <div class="col-md-6" style="margin-bottom: 1em">
35 43
                 <eva-icon name="person" fill="#60CBEB"></eva-icon>
36
-                <input class="form-control" type="text" name="name" placeholder="Name" />
44
+                <input
45
+                  class="form-control"
46
+                  type="text"
47
+                  name="name"
48
+                  placeholder="Name"
49
+                  v-model="registerAgency.user.name"
50
+                />
37 51
               </div>
38 52
               <div class="col-md-6" style="margin-bottom: 1em">
39 53
                 <eva-icon name="person" fill="#60CBEB"></eva-icon>
40
-                <input class="form-control" type="text" name="surname" placeholder="Surname" />
54
+                <input
55
+                  class="form-control"
56
+                  type="text"
57
+                  name="surname"
58
+                  placeholder="Surname"
59
+                  v-model="registerAgency.user.surname"
60
+                />
41 61
               </div>
42 62
             </div>
43 63
 
44 64
             <div class="row" style="text-align:left">
45 65
               <div class="col-md-8">
46 66
                 <eva-icon name="email" fill="#60CBEB"></eva-icon>
47
-                <input class="form-control" type="text" name="email" placeholder="Email Address" />
67
+                <input
68
+                  class="form-control"
69
+                  type="text"
70
+                  name="email"
71
+                  placeholder="Email Address"
72
+                  v-model="registerAgency.user.email"
73
+                />
48 74
                 <div class="form-group row"></div>
49 75
               </div>
50 76
 
@@ -55,6 +81,7 @@
55 81
                   type="text"
56 82
                   name="cellnumber"
57 83
                   placeholder="Contact Number"
84
+                  v-model="registerAgency.user.cellNumber"
58 85
                 />
59 86
               </div>
60 87
             </div>
@@ -62,14 +89,20 @@
62 89
             <div class="row">
63 90
               <div class="col-md-7" style="margin-bottom: 1em">
64 91
                 <eva-icon name="person" fill="#60CBEB"></eva-icon>
65
-                <input class="form-control" type="text" name="username" placeholder="Username" />
92
+                <input
93
+                  class="form-control"
94
+                  type="text"
95
+                  name="username"
96
+                  placeholder="Username"
97
+                  v-model="registerAgency.user.username"
98
+                />
66 99
               </div>
67 100
               <div class="col-md-7" style="margin-bottom: 1em">
68 101
                 <eva-icon name="lock" fill="#60CBEB"></eva-icon>
69 102
                 <input
70 103
                   class="form-control"
71 104
                   :type="isPasswordShown"
72
-                  v-model="password"
105
+                  v-model="registerAgency.user.password"
73 106
                   id="password"
74 107
                   placeholder="Password"
75 108
                   name="password"
@@ -81,7 +114,7 @@
81 114
                 <input
82 115
                   class="form-control"
83 116
                   :type="isPasswordShown"
84
-                  v-model="password"
117
+                  v-model="registerAgency.user.password"
85 118
                   id="password"
86 119
                   placeholder="Confirm Password"
87 120
                   name="confirmpassword"
@@ -102,10 +135,10 @@
102 135
           <div class="form-group row"></div>
103 136
           <div class="row offset-md-1">
104 137
             <div class="col-md-2">
105
-              <button class="btn btn-b-n" type="submit">Submit</button>
138
+              <button @click="SubmitData()" class="btn btn-b-n" type="button">Submit</button>
106 139
             </div>
107 140
             <div class="col-md-2 offset-md-1">
108
-              <button class="btn btn-b-n" type="submit">Cancel</button>
141
+              <button @click="Cancel()" class="btn btn-b-n" type="button">Cancel</button>
109 142
             </div>
110 143
           </div>
111 144
         </div>
@@ -115,19 +148,19 @@
115 148
 </template>
116 149
 
117 150
 <script>
118
-import RegisterPage from './registerPage.vue';
151
+import { mapState, mapActions } from 'vuex';
152
+// import RegisterPage from './registerPage.vue';
119 153
 
120 154
 export default {
121
-  data() {
122
-    return {
123
-      RegisterHeader: 'Agency Administrator Details',
124
-    };
125
-  },
155
+  // data() {
156
+  //   return {
157
+  //     RegisterHeader: 'Agency Administrator Details',
158
+  //   };
159
+  // },
126 160
   name: 'Agency',
127
-  components: { RegisterPage },
161
+  // components: { RegisterPage },
128 162
   data() {
129 163
     return {
130
-      username: '',
131 164
       user: null,
132 165
       isPasswordShown: 'password',
133 166
       selectItems: [{ text: 'password', value: 0 }],
@@ -136,10 +169,19 @@ export default {
136 169
       textErrors: 'Some error with the field',
137 170
       text: '',
138 171
       showPassword: false,
139
-      password: '',
140 172
     };
141 173
   },
174
+  computed: {
175
+    ...mapState('registerAgency', ['registerAgency']),
176
+  },
142 177
   methods: {
178
+    ...mapActions('registerAgency', [
179
+      'getAgency',
180
+      'saveAgency',
181
+      'updateAgency',
182
+      'clearAgency',
183
+    ]),
184
+
143 185
     togglePassword() {
144 186
       this.showPassword = true;
145 187
       this.isPasswordShown = 'text';
@@ -148,6 +190,13 @@ export default {
148 190
       this.showPassword = false;
149 191
       this.isPasswordShown = 'password';
150 192
     },
193
+    SubmitData() {
194
+      this.saveAgency(this.registerAgency);
195
+      this.$router.push('/registerAgency/');
196
+    },
197
+    Close() {
198
+      this.$router.push('/registerAgency/');
199
+    },
151 200
   },
152 201
 };
153 202
 </script>

+ 52
- 10
src/components/user/registerPage.vue Bestand weergeven

@@ -8,18 +8,36 @@
8 8
           <div class="row" style="text-align:left">
9 9
             <div class="col-md-6" style="margin-bottom: 1em">
10 10
               <eva-icon name="person" fill="#60CBEB"></eva-icon>
11
-              <input class="form-control" type="text" name="name" placeholder="Name" />
11
+              <input
12
+                class="form-control"
13
+                type="text"
14
+                name="name"
15
+                placeholder="Name"
16
+                v-model="registerIndividual.name"
17
+              />
12 18
             </div>
13 19
             <div class="col-md-6" style="margin-bottom: 1em">
14 20
               <eva-icon name="person" fill="#60CBEB"></eva-icon>
15
-              <input class="form-control" type="text" name="surname" placeholder="Surname" />
21
+              <input
22
+                class="form-control"
23
+                type="text"
24
+                name="surname"
25
+                placeholder="Surname"
26
+                v-model="registerIndividual.surname"
27
+              />
16 28
             </div>
17 29
           </div>
18 30
 
19 31
           <div class="row" style="text-align:left">
20 32
             <div class="col-md-8">
21 33
               <eva-icon name="email" fill="#60CBEB"></eva-icon>
22
-              <input class="form-control" type="text" name="email" placeholder="Email Address" />
34
+              <input
35
+                class="form-control"
36
+                type="text"
37
+                name="email"
38
+                placeholder="Email Address"
39
+                v-model="registerIndividual.email"
40
+              />
23 41
               <div class="form-group row"></div>
24 42
             </div>
25 43
 
@@ -30,6 +48,7 @@
30 48
                 type="text"
31 49
                 name="cellnumber"
32 50
                 placeholder="Contact Number"
51
+                v-model="registerIndividual.cellNumber"
33 52
               />
34 53
             </div>
35 54
           </div>
@@ -37,14 +56,20 @@
37 56
           <div class="row">
38 57
             <div class="col-md-7" style="margin-bottom: 1em">
39 58
               <eva-icon name="person" fill="#60CBEB"></eva-icon>
40
-              <input class="form-control" type="text" name="username" placeholder="Username" />
59
+              <input
60
+                class="form-control"
61
+                type="text"
62
+                name="username"
63
+                placeholder="Username"
64
+                v-model="registerIndividual.username"
65
+              />
41 66
             </div>
42 67
             <div class="col-md-7" style="margin-bottom: 1em">
43 68
               <eva-icon name="lock" fill="#60CBEB"></eva-icon>
44 69
               <input
45 70
                 class="form-control"
46 71
                 :type="isPasswordShown"
47
-                v-model="password"
72
+                v-model="registerIndividual.password"
48 73
                 id="password"
49 74
                 placeholder="Password"
50 75
                 name="password"
@@ -56,7 +81,7 @@
56 81
               <input
57 82
                 class="form-control"
58 83
                 :type="isPasswordShown"
59
-                v-model="password"
84
+                v-model="registerIndividual.password"
60 85
                 id="password"
61 86
                 placeholder="Confirm Password"
62 87
                 name="confirmpassword"
@@ -77,10 +102,10 @@
77 102
         <div class="form-group row"></div>
78 103
         <div class="row offset-md-1">
79 104
           <div class="col-md-2">
80
-            <button class="btn btn-b-n" type="submit">Submit</button>
105
+            <button @click="SubmitData()" class="btn btn-b-n" type="submit">Submit</button>
81 106
           </div>
82 107
           <div class="col-md-2 offset-md-1">
83
-            <button class="btn btn-b-n" type="submit">Cancel</button>
108
+            <button @click="Cancel()" class="btn btn-b-n" type="submit">Cancel</button>
84 109
           </div>
85 110
         </div>
86 111
       </div>
@@ -89,6 +114,8 @@
89 114
 </template>
90 115
 
91 116
 <script>
117
+import { mapState, mapActions } from 'vuex';
118
+
92 119
 export default {
93 120
   props: {
94 121
     RegisterHeader: { type: String, default: undefined },
@@ -96,7 +123,6 @@ export default {
96 123
   name: 'PrivateIndividual',
97 124
   data() {
98 125
     return {
99
-      username: '',
100 126
       user: null,
101 127
       isPasswordShown: 'password',
102 128
       selectItems: [{ text: 'password', value: 0 }],
@@ -105,10 +131,11 @@ export default {
105 131
       textErrors: 'Some error with the field',
106 132
       text: '',
107 133
       showPassword: false,
108
-      password: '',
109 134
     };
110 135
   },
111 136
   computed: {
137
+    ...mapState('registerIndividual', ['registerIndividual']),
138
+
112 139
     Header() {
113 140
       return this.RegisterHeader
114 141
         ? 'Agency Administrator Details'
@@ -116,6 +143,13 @@ export default {
116 143
     },
117 144
   },
118 145
   methods: {
146
+    ...mapActions('registerIndividual', [
147
+      'getIndividual',
148
+      'saveIndividual',
149
+      'updateIndividual',
150
+      'clearIndividual',
151
+    ]),
152
+
119 153
     togglePassword() {
120 154
       this.showPassword = true;
121 155
       this.isPasswordShown = 'text';
@@ -124,6 +158,14 @@ export default {
124 158
       this.showPassword = false;
125 159
       this.isPasswordShown = 'password';
126 160
     },
161
+    SubmitData() {
162
+      this.saveIndividual(this.registerIndividual);
163
+
164
+      this.$router.push('/registerIndividual/');
165
+    },
166
+    Close() {
167
+      this.$router.push('/registerIndividual/');
168
+    },
127 169
   },
128 170
 };
129 171
 </script>

+ 3
- 0
src/store/index.js Bestand weergeven

@@ -13,6 +13,7 @@ import WeekModule from './modules/timeshare/week';
13 13
 import PropertyAdminModule from './modules/property/propertyAdmin';
14 14
 import PropertyList from './modules/property/propertyLists';
15 15
 import PropertyTypes from './modules/property/propertyTypes';
16
+import Register from './modules/user/register';
16 17
 
17 18
 Vue.use(Vuex);
18 19
 /* eslint no-param-reassign: ["error", { "props": false }] */
@@ -30,5 +31,7 @@ export default new Vuex.Store({
30 31
     propertyAdmin: PropertyAdminModule,
31 32
     propertyList: PropertyList,
32 33
     propertyTypes: PropertyTypes,
34
+    registerIndividual: Register,
35
+    registerAgency: Register,
33 36
   },
34 37
 });

+ 161
- 0
src/store/modules/user/register.js Bestand weergeven

@@ -0,0 +1,161 @@
1
+import axios from 'axios';
2
+
3
+export default {
4
+  namespaced: true,
5
+  state: {
6
+    registerIndividual: {
7
+      name: '',
8
+      surname: '',
9
+      email: '',
10
+      cellNumber: '',
11
+      username: '',
12
+      password: '',
13
+    },
14
+    registerAgency: {
15
+      name: '',
16
+      eaabeffcNumber: '',
17
+      companyRegNumber: '',
18
+      user: {
19
+        name: '',
20
+        surname: '',
21
+        email: '',
22
+        cellNumber: '',
23
+        username: '',
24
+        password: '',
25
+      },
26
+    },
27
+  },
28
+  mutations: {
29
+    setIndividual(state, type) {
30
+      state.registerIndividual = type;
31
+    },
32
+    setAgency(state, type) {
33
+      state.registerAgency = type;
34
+    },
35
+    addIndividual(state, type) {
36
+      state.registerIndividual = type;
37
+    },
38
+    addAgency(state, type) {
39
+      state.registerAgency = type;
40
+    },
41
+    updateIndividual(state, type) {
42
+      state.registerIndividual.find(item => item.id === type.id).username = type.username;
43
+      state.registerIndividual.find(item => item.id === type.id).password = type.password;
44
+    },
45
+    updateAgency(state, type) {
46
+      state.registerAgency.find(item => item.id === type.id).eaabeffcNumber = type
47
+        .eaabeffcNumber;
48
+      state.registerAgency.find(item => item.id === type.id).companyRegNumber = type
49
+        .companyRegNumber;
50
+    },
51
+    clearIndividual(state) {
52
+      state.registerIndividual = {
53
+        name: '',
54
+        surname: '',
55
+        email: '',
56
+        cellNumber: '',
57
+        username: '',
58
+        password: '',
59
+      };
60
+    },
61
+    clearAgency(state) {
62
+      state.registerAgency = {
63
+        name: '',
64
+        eaabeffcNumber: '',
65
+        companyRegNumber: '',
66
+        user: {
67
+          name: '',
68
+          surname: '',
69
+          email: '',
70
+          cellNumber: '',
71
+          username: '',
72
+          password: '',
73
+        },
74
+      };
75
+    },
76
+    removeIndividual(state, id) {
77
+      state.registerIndividual.pop(state.registerIndividual.find(p => p.id === id));
78
+    },
79
+    removeAgency(state, id) {
80
+      state.registerAgency.pop(state.registerAgency.find(a => a.id === id));
81
+    },
82
+  },
83
+  getters: {},
84
+  actions: {
85
+    // getIndividual({
86
+    //   commit,
87
+    // }, id) {
88
+    //   axios
89
+    //     .get(`http://localhost:57260/api/user/${id}`)
90
+    //     .then(result => commit('setIndividual', result.data))
91
+    //     .catch(console.error);
92
+    // },
93
+    // getAgency({
94
+    //   commit,
95
+    // }, id) {
96
+    //   axios
97
+    //     .get(`http://localhost:57260/api/agency/${id}`)
98
+    //     .then(result => commit('setAgency', result.data))
99
+    //     .catch(console.error);
100
+    // },
101
+
102
+    saveIndividual({
103
+      commit,
104
+    }, item) {
105
+      axios
106
+        .post('http://localhost:57260/api/register/register', item)
107
+        .then(result => commit('addIndividual', result.data))
108
+        .catch(console.error);
109
+    },
110
+    saveAgency({
111
+      commit,
112
+    }, item) {
113
+      axios
114
+        .post('http://localhost:57260/api/register/registeragency', item)
115
+        .then(result => commit('addAgency', result.data))
116
+        .catch(console.error);
117
+    },
118
+    // updateIndividual({
119
+    //   commit,
120
+    // }, item) {
121
+    //   axios
122
+    //     .put('http://localhost:57260/api/individual', item)
123
+    //     .then(result => commit('updateIndividual', item))
124
+    //     .catch(console.error);
125
+    // },
126
+    // updateAgency({
127
+    //   commit,
128
+    // }, item) {
129
+    //   axios
130
+    //     .put('http://localhost:57260/api/agency', item)
131
+    //     .then(result => commit('updateAgency', item))
132
+    //     .catch(console.error);
133
+    // },
134
+    // clearIndividual({
135
+    //   commit,
136
+    // }) {
137
+    //   commit('clearIndividual');
138
+    // },
139
+    // clearAgency({
140
+    //   commit,
141
+    // }) {
142
+    //   commit('clearAgency');
143
+    // },
144
+    // deleteIndividual({
145
+    //   commit,
146
+    // }, id) {
147
+    //   axios
148
+    //     .delete(`http://localhost:57260/api/individual/${id}`)
149
+    //     .then(result => commit('removeIndividual', id))
150
+    //     .catch(console.error);
151
+    // },
152
+    // deleteAgency({
153
+    //   commit,
154
+    // }, id) {
155
+    //   axios
156
+    //     .delete(`http://localhost:57260/api/agency/${id}`)
157
+    //     .then(result => commit('removeAgency', id))
158
+    //     .catch(console.error);
159
+    // },
160
+  },
161
+};

Laden…
Annuleren
Opslaan