Bläddra i källkod

Add Validation to forms

master
Brian Conway 2 år sedan
förälder
incheckning
6656b37134

+ 876
- 849
public/css/newStyle.css
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 116
- 56
src/components/shared/contactUsSection.vue Visa fil

@@ -2,72 +2,76 @@
2 2
   <div>
3 3
     <h4 align="left" class="contactHeader">Send us a message</h4>
4 4
     <div class="form">
5
-      <div id="sendmessage">Your message has been sent. Thank you!</div>
6
-      <div id="errormessage"></div>
5
+      <div v-if="boolValidationError" class="row">
6
+        <div class="col">
7
+          <alert :text="errorMessage" :type="errorOccurred" />
8
+        </div>
9
+      </div>
7 10
       <div class="form-row">
8 11
         <div class="form-group col-md-6">
9 12
           <input
10
-            type="text"
11
-            name="name"
12
-            class="form-control"
13
-            id="name"
14
-            placeholder="Name"
15
-            data-rule="minlen:4"
16
-            data-msg="Please enter your name"
17
-            v-model="name"
18
-          />
19
-          <div class="validation"></div>
13
+              type="text"
14
+              id="name"
15
+              class="form-control"
16
+              v-model="name"
17
+              v-bind:class="{'is-valid': name,
18
+                'is-invalid': !requiredField(name) && nameLoad}"
19
+              v-on:keyup="nameLoad = true"
20
+              v-on:blur="nameLoad = true"
21
+              placeholder="Name"
22
+            />
23
+            <div class="invalid-feedback">Name is required!</div>
20 24
         </div>
21 25
         <div class="form-group col-md-6">
22 26
           <input
23
-            type="email"
24
-            class="form-control"
25
-            name="email"
26
-            id="email"
27
-            placeholder="Email"
28
-            data-rule="email"
29
-            data-msg="Please enter a valid email"
30
-            v-model="email"
31
-          />
32
-          <div class="validation"></div>
27
+              type="email"
28
+              id="email"
29
+              v-model="email"
30
+              class="form-control"
31
+              v-bind:class="{'is-valid': email,
32
+                'is-invalid': !validEmail(email) && emailLoad}"
33
+              v-on:keyup="emailLoad = true"
34
+              v-on:blur="emailLoad = true"
35
+              placeholder="Email"
36
+            />
37
+            <div class="invalid-feedback">Valid email address is required!</div>
33 38
         </div>
34 39
         <div class="form-group col-md-6">
35 40
           <input
36 41
             type="text"
37
-            name="phone"
38
-            class="form-control"
39 42
             id="phone"
40
-            placeholder="Phone"
41
-            data-rule="minlen:10"
42
-            data-msg="Please enter at least 10 numbers"
43 43
             v-model="phone"
44
+            class="form-control"
45
+            v-bind:class="{'is-valid': phone}"
46
+            placeholder="Phone Number"
44 47
           />
45
-          <div class="validation"></div>
46 48
         </div>
47 49
         <div class="form-group col-md-6">
48 50
           <input
49 51
             type="text"
50
-            class="form-control"
51
-            name="property"
52 52
             id="property"
53
-            placeholder="Property"
54
-            data-msg="Please enter the property you are interested in"
55 53
             v-model="property"
54
+            class="form-control"
55
+            v-bind:class="{'is-valid': property}"
56
+            placeholder="Property"
56 57
           />
57
-          <div class="validation"></div>
58 58
         </div>
59 59
       </div>
60 60
       <div class="form-group">
61
+
61 62
         <textarea
62
-          class="form-control"
63
-          name="message"
63
+          type="text"
64
+          id="message"
64 65
           rows="5"
65
-          data-rule="required"
66
-          data-msg="Please write something for us"
67
-          placeholder="Message"
66
+          class="form-control"
68 67
           v-model="message"
68
+          v-bind:class="{'is-valid': message,
69
+            'is-invalid': !requiredField(message) && messageLoad}"
70
+          v-on:keyup="messageLoad = true"
71
+          v-on:blur="messageLoad = true"
72
+          placeholder="Message"
69 73
         ></textarea>
70
-        <div class="validation"></div>
74
+        <div class="invalid-feedback">Message is required!</div>
71 75
       </div>
72 76
       <div class="text-center">
73 77
         <button class="btn-solid-blue" @click="sendMail()">SEND</button>
@@ -96,7 +100,13 @@ export default {
96 100
       phone: null,
97 101
       property: null,
98 102
       message: null,
99
-      boolSent: false
103
+      boolSent: false,
104
+      errorOccurred: "",
105
+      errorMessage: "",
106
+      boolValidationError: false,
107
+      nameLoad: false,
108
+      emailLoad: false,
109
+      messageLoad: false
100 110
     };
101 111
   },
102 112
   mounted() {
@@ -104,29 +114,79 @@ export default {
104 114
   },
105 115
   methods: {
106 116
     async sendMail() {
107
-      var mailObj = {
108
-        //toAddress: "abigaildf@provision-sa.com",
109
-        //fromAddress: "jlouw365@gmail.com",
110
-        name: this.name,
111
-        email: this.email,
112
-        phone: this.phone,
113
-        property: this.property,
114
-        message: this.message
115
-      };
117
+      if (this.validatePage()) {
118
+        var mailObj = {
119
+          name: this.name,
120
+          email: this.email,
121
+          phone: this.phone,
122
+          property: this.property,
123
+          message: this.message
124
+        };
116 125
 
117
-      const response = await axios.post("/api/mail/0", mailObj);
118
-
119
-      if (response.status === 200) {
120
-        this.boolSent = true;
121
-      } else {
122
-        console.log("Error");
126
+      await axios
127
+        .post("/api/mail/0", mailObj)
128
+        .then((response) => {
129
+          //console.log('Response');
130
+          //console.log(response);
131
+            this.boolSent = true;
132
+        })
133
+        .catch((err) => {
134
+              this.boolValidationError = true;
135
+              this.errorOccurred = "ERROR";
136
+              this.errorMessage = "Server Error: CONNECTION_REFUSED";
137
+              if (err) {
138
+                //console.log('Error');
139
+                //console.log(err.response.status);
140
+                if (err.response.status) {
141
+                  this.boolSent = true;
142
+                  this.boolValidationError = false;
143
+                } else {
144
+                  this.boolSent = false;
145
+                }
146
+              } else {
147
+                console.log('no err')
148
+                boolSent = false;
149
+              }
150
+        })
123 151
       }
124 152
     },
125 153
     countDownChanged(dismissCountDown) {
126 154
       this.dismissCountDown = dismissCountDown;
155
+    },
156
+    validatePage : function(){
157
+      //console.log('validatePage')
158
+      if (this.name && this.email){
159
+        this.errorOccurred = '';
160
+        this.errorMessage = '';
161
+        this.boolValidationError = false;
162
+        return true;
163
+      } else {
164
+        this.boolValidationError = true;
165
+        this.nameLoad = true;
166
+        this.emailLoad = true;
167
+        this.messageLoad = true;
168
+        this.errorOccurred = "ERROR";
169
+        this.errorMessage = "Please check form and correct all input fields!";
170
+        return false;
171
+      }
172
+    },
173
+    requiredField : function(tfield) {
174
+      if(tfield){
175
+        return true;
176
+      } else {
177
+        return false;
178
+      }
179
+    },
180
+    validEmail : function(temail) {
181
+        var re = /(.+)@(.+){2,}\.(.+){2,}/;
182
+        return re.test(temail);
127 183
     }
128 184
   }
129 185
 };
130 186
 </script>
131 187
 
132
-<style lang="scss" scoped></style>
188
+<style lang="scss" scoped>
189
+.form input{
190
+  text-transform: none;
191
+}
192
+</style>

+ 2
- 2
src/components/user/loginPage.vue Visa fil

@@ -161,8 +161,8 @@ export default {
161 161
           }
162 162
         })
163 163
         .catch(err => {
164
-          console.log("Catch here");
165
-          console.log(this.status);
164
+          //console.log("Catch here");
165
+          //console.log(this.status);
166 166
           this.errorOccurred = "ERROR";
167 167
           this.errorMessage = "Server Error: CONNECTION_REFUSED"; 
168 168
           console.log(err.status);

+ 312
- 169
src/components/user/registerAgencySection.vue Visa fil

@@ -1,179 +1,243 @@
1 1
 <template>
2
-  <div class="col-10 mx-auto">
3
-    <h3 class="card-title text-center">Agency Details</h3>
4
-    <div class="row my-3">
5
-      <div class="col-sm-12 col-md-6">
6
-        <input
7
-          type="text"
8
-          id="inputAgencyName"
9
-          v-model="registerAgency.name"
10
-          class="form-control uniInput"
11
-          placeholder="Agency Name"
12
-          required
13
-          autofocus
14
-        />
2
+  <main id="main" style="padding-top:10px; padding-bottom:50px">
3
+    <div class="container">
4
+      <div v-if="boolMessage" class="row">
5
+        <div class="col">
6
+          <alert :text="'Register Success!'" :type="'SUCCESS'" />
7
+        </div>
15 8
       </div>
16
-      <div class="col-sm-12 col-md-6">
17
-        <input
18
-          type="text"
19
-          id="inputAgencyNumber"
20
-          v-model="registerAgency.eaabeffcNumber"
21
-          class="form-control uniInput"
22
-          placeholder="EAAB FFC Number"
23
-          required
24
-          autofocus
25
-        />
9
+      <div v-if="boolValidationError" class="row">
10
+        <div class="col">
11
+          <alert :text="errorMessage" :type="errorOccurred" />
12
+        </div>
26 13
       </div>
27
-    </div>
28
-    <div class="row my-3">
29
-      <div class="col-sm-12">
30
-        <input
31
-          type="text"
32
-          id="inputAgencyCompanyRegistration"
33
-          v-model="registerAgency.companyRegNumber"
34
-          class="form-control uniInput"
35
-          placeholder="Company Registration Number"
36
-          required
37
-          autofocus
38
-        />
39
-      </div>
40
-    </div>
41
-    <h3 class="card-title text-center">Agency Administrator</h3>
42
-    <hr />
43
-    <div class="row my-3">
44
-      <div class="col-sm-12 col-md-6">
45
-        <input
46
-          type="text"
47
-          id="inputAgencyAdmin"
48
-          v-model="registerAgency.user.name"
49
-          class="form-control uniInput my-3"
50
-          placeholder="Name"
51
-          required
52
-          autofocus
53
-        />
54
-
55
-        <input
56
-          type="text"
57
-          id="inputAgencySurname"
58
-          v-model="registerAgency.user.surname"
59
-          class="form-control uniInput my-3"
60
-          placeholder="Surname"
61
-          required
62
-          autofocus
63
-        />
64
-
65
-        <input
66
-          type="email"
67
-          id="inputAgencyEmail"
68
-          v-model="registerAgency.user.email"
69
-          class="form-control uniInput my-3"
70
-          placeholder="Email"
71
-          required
72
-          autofocus
73
-        />
14
+      <h3 class="card-title text-center">Agency Details</h3>
15
+      <div class="row my-3">
16
+        <div class="col-sm-12 col-md-6">
17
+          <div class="form-group">
18
+            <input
19
+              type="text"
20
+              id="inputAgencyName"
21
+              v-model="registerAgency.name"
22
+              class="form-control uniInput"
23
+              v-bind:class="{'is-valid': registerAgency.name,
24
+                'is-invalid': !requiredField(registerAgency.name) && agencyNameLoad}"
25
+              v-on:keyup="agencyNameLoad = true"
26
+              v-on:blur="agencyNameLoad = true"
27
+              placeholder="Agency Name"
28
+            />
29
+            <div class="invalid-feedback">Agency Name is required!</div>
30
+          </div>
31
+        </div>
32
+        <div class="col-sm-12 col-md-6">
33
+          <div class="form-group">
34
+            <input
35
+              type="text"
36
+              id="inputAgencyNumber"
37
+              v-model="registerAgency.eaabeffcNumber"
38
+              class="form-control uniInput"
39
+              v-bind:class="{'is-valid': registerAgency.eaabeffcNumber,
40
+                'is-invalid': !requiredField(registerAgency.eaabeffcNumber) && agencyNumberLoad}"
41
+              v-on:keyup="agencyNumberLoad = true"
42
+              v-on:blur="agencyNumberLoad = true"
43
+              placeholder="EAAB FFC Number"
44
+            />
45
+            <div class="invalid-feedback">Agency Number is required!</div>
46
+          </div>
47
+        </div>
74 48
       </div>
75
-      <div class="col-sm-12 col-md-6">
76
-        <input
77
-          type="text"
78
-          id="inputAgencyCellphone"
79
-          v-model="registerAgency.user.cellNumber"
80
-          class="form-control uniInput my-3"
81
-          placeholder="Cellphone Number"
82
-          required
83
-          autofocus
84
-        />
85
-
86
-        <input
87
-          type="text"
88
-          id="inputAgencyLandLine"
89
-          v-model="registerAgency.user.telephone"
90
-          class="form-control uniInput"
91
-          placeholder="Landline Number"
92
-          required
93
-          autofocus
94
-        />
49
+      <div class="row my-3">
50
+       <div class="col-sm-12">
51
+         <div class="form-group">
52
+          <input
53
+            type="text"
54
+            id="inputAgencyCompanyRegistration"
55
+            v-model="registerAgency.companyRegNumber"
56
+            class="form-control uniInput"
57
+            v-bind:class="{'is-valid': registerAgency.companyRegNumber,
58
+             'is-invalid': !requiredField(registerAgency.companyRegNumber) && companyRegNumberLoad}"
59
+            v-on:keyup="companyRegNumberLoad = true"
60
+            v-on:blur="companyRegNumberLoad = true"
61
+            placeholder="Company Registration Number"
62
+          />
63
+         <div class="invalid-feedback">Company Registration Number is required!</div>
64
+        </div>
65
+       </div>
95 66
       </div>
96
-    </div>
97
-    <hr />
98
-    <div class="row my-3">
99
-      <div class="col-sm-12">
100
-        <input
101
-          type="text"
102
-          id="inputAgencyUsername"
103
-          v-model="registerAgency.user.username"
104
-          class="form-control uniInput"
105
-          placeholder="Username"
106
-          required
107
-          autofocus
108
-        />
67
+      <h3 class="card-title text-center">Agency Administrator</h3>
68
+      <hr />
69
+      <div class="row my-3">
70
+        <div class="col-sm-12 col-md-6">
71
+          <div class="form-group">
72
+            <input
73
+              type="text"
74
+              id="inputAgencyAdmin"
75
+              v-model="registerAgency.user.name"
76
+              class="form-control uniInput my-3"
77
+              v-bind:class="{'is-valid': registerAgency.user.name,
78
+                'is-invalid': !requiredField(registerAgency.user.name) && agencyAdminNameLoad}"
79
+              v-on:keyup="agencyAdminNameLoad = true"
80
+              v-on:blur="agencyAdminNameLoad = true"
81
+              placeholder="Name"
82
+            />
83
+            <div class="invalid-feedback">Administrator Name is required!</div>
84
+          </div>
85
+          <div class="form-group">
86
+            <input
87
+              type="text"
88
+              id="inputAgencySurname"
89
+              v-model="registerAgency.user.surname"
90
+              class="form-control uniInput my-3"
91
+              v-bind:class="{'is-valid': registerAgency.user.surname,
92
+                'is-invalid': !requiredField(registerAgency.user.surname) && agencySurnameLoad}"
93
+              v-on:keyup="agencySurnameLoad = true"
94
+              v-on:blur="agencySurnameLoad = true"
95
+              placeholder="Surname"
96
+            />
97
+            <div class="invalid-feedback">Administrator Surname is required!</div>
98
+          </div>
99
+          <div class="form-group">
100
+            <input
101
+              type="email"
102
+              id="inputAgencyEmail"
103
+              v-model="registerAgency.user.email"
104
+              v-bind:class="{'is-valid': registerAgency.user.email,
105
+                'is-invalid': !validEmail(registerAgency.user.email) && agencyEmailLoad}"
106
+              v-on:keyup="agencyEmailLoad = true"
107
+              v-on:blur="agencyEmailLoad = true"
108
+              class="form-control uniInput my-3"
109
+              placeholder="Email"
110
+            />
111
+            <div class="invalid-feedback">Valid email is required!</div>
112
+          </div>
113
+        </div>
114
+        <div class="col-sm-12 col-md-6">
115
+          <div class="form-group">
116
+            <input
117
+              type="text"
118
+              id="inputAgencyCellphone"
119
+              v-model="registerAgency.user.cellNumber"
120
+              class="form-control uniInput my-3"
121
+              v-bind:class="{'is-valid': registerAgency.user.cellNumber,
122
+                'is-invalid': !requiredField(registerAgency.user.cellNumber)
123
+                 && agencyCellNumberLoad}"
124
+              v-on:keyup="agencyCellNumberLoad = true"
125
+              v-on:blur="agencyCellNumberLoad = true"
126
+              placeholder="Cellphone Number"
127
+            />
128
+            <div class="invalid-feedback">Cell number is required!</div>
129
+          </div>
130
+          <div class="form-group">
131
+            <input
132
+              type="text"
133
+              id="inputAgencyLandLine"
134
+              v-model="registerAgency.user.telephone"
135
+              class="form-control uniInput"
136
+              v-bind:class="{'is-valid': registerAgency.user.telephone}"
137
+              placeholder="Landline Number"
138
+            />
139
+          </div>
140
+        </div>
109 141
       </div>
110
-    </div>
111
-    <div class="row my-3">
112
-      <div class="col-sm-12 col-md-6">
113
-        <input
114
-          type="password"
115
-          placeholder="Password"
116
-          v-model="registerAgency.user.password"
117
-          id="inputAgencyPassword uniInput"
118
-          class="form-control uniInput"
119
-          required
120
-        />
142
+      <hr />
143
+      <div class="row my-3">
144
+        <div class="col-sm-12">
145
+          <div class="form-group">
146
+            <input
147
+              type="text"
148
+              id="inputAgencyUsername"
149
+              v-model="registerAgency.user.username"
150
+              class="form-control uniInput"
151
+              v-bind:class="{'is-valid': registerAgency.user.username,
152
+                'is-invalid': !requiredField(registerAgency.user.username) && agencyusernameLoad}"
153
+              v-on:keyup="agencyusernameLoad = true"
154
+              v-on:blur="agencyusernameLoad = true"
155
+              placeholder="Username"
156
+            />
157
+            <div class="invalid-feedback">Username is required!</div>
158
+          </div>
159
+        </div>
121 160
       </div>
122
-      <div class="col">
123
-        <input
124
-          type="password"
125
-          placeholder="Confirm Password"
126
-          v-model="registerAgency.user.password"
127
-          id="inputAgencyPasswordConfirm"
128
-          class="form-control uniInput"
129
-          required
130
-        />
161
+      <div class="row my-3">
162
+        <div class="col-sm-12 col-md-6">
163
+          <div class="form-group">
164
+            <input
165
+              type="password"
166
+              placeholder="Password"
167
+              v-model="registerAgency.user.password"
168
+              id="inputAgencyPassword uniInput"
169
+              class="form-control uniInput"
170
+              v-bind:class="{'is-valid': registerAgency.user.password,
171
+                'is-invalid': !requiredField(registerAgency.user.password) && agencypasswordLoad}"
172
+              v-on:keyup="agencypasswordLoad = true"
173
+              v-on:blur="agencypasswordLoad = true"
174
+            />
175
+            <div class="invalid-feedback">Password is required!</div>
176
+          </div>
177
+        </div>
178
+        <div class="col">
179
+          <div class="form-group">
180
+            <input
181
+              type="password"
182
+              placeholder="Confirm Password"
183
+              v-model="registerAgency.user.confirm"
184
+              id="inputAgencyPasswordConfirm"
185
+              class="form-control uniInput"
186
+              v-bind:class="{'is-valid': registerAgency.user.confirm,
187
+                'is-invalid': !validConfirm(registerAgency.user.confirm) && agencyconfirmLoad}"
188
+              v-on:keyup="agencyconfirmLoad = true"
189
+              v-on:blur="agencyconfirmLoad = true"
190
+            />
191
+            <div class="invalid-feedback">Password and Confirm password must be the same!</div>
192
+          </div>
193
+        </div>
131 194
       </div>
132
-    </div>
133
-    <div class="row">
134
-      <div class="col">
135
-        <label for="tc"
136
-          ><router-link to="/termsConditionsView">Terms & Conditions</router-link></label
137
-        >
138
-        <input
139
-          name="tc"
140
-          type="checkbox"
141
-          class="ml-3 mt-2"
142
-          v-model="registerAgency.user.acceptedTerms"
143
-        />
195
+      <div class="row">
196
+        <div class="col">
197
+          <label for="agencytc"
198
+            ><router-link to="/termsConditionsView">Terms & Conditions</router-link></label
199
+          >
200
+          <input
201
+            name="agencytc"
202
+            type="checkbox"
203
+            class="ml-3 mt-2"
204
+            v-model="registerAgency.user.acceptedTerms"
205
+          />
206
+        </div>
144 207
       </div>
145
-    </div>
146
-    <button
208
+      <button
147 209
         v-if="registerAgency.user.acceptedTerms"
148
-        :disabled="isDisabled"
210
+        class="btn-white-border"
149 211
         v-on:click="SubmitData()"
150
-        :class="isDisabled ? 'btn-disabled' : 'btn-solid-blue'"
151 212
         type="submit"
152
-    >
213
+      >
153 214
       SUBMIT
154
-    </button>
155
-    <button
215
+      </button>
216
+      <button
156 217
       :data-target="'#myModalAgency'"
157 218
       data-toggle="modal"
158 219
       @click="navigate()"
159 220
       class="btn-white-border mb-5"
160 221
       style="float:right"
161 222
       type="submit"
162
-    >
223
+      >
163 224
       Cancel
164
-    </button>
165
-    <button hidden :data-target="'#myModalAgency'" data-toggle="modal" ref="dataToggle"></button>
166
-  </div>
225
+      </button>
226
+      <button hidden :data-target="'#myModalAgency'" data-toggle="modal" ref="dataToggle"></button>
227
+    </div>
228
+  </main>
167 229
 </template>
168 230
 
169 231
 <script>
170 232
 /* eslint-disable */
171 233
 import { mapState, mapActions } from "vuex";
172 234
 import carousel from "vue-owl-carousel";
235
+import alert from "../shared/alert";
173 236
 import Log from "../../assets/Log";
174 237
 export default {
175 238
   components: {
176
-    carousel
239
+    carousel,
240
+    alert
177 241
   },
178 242
   props: {
179 243
     RegisterHeader: { type: String, default: undefined }
@@ -181,18 +245,30 @@ export default {
181 245
   name: "Agency",
182 246
   data() {
183 247
     return {
184
-      user: null,
185 248
       isPasswordShown: "password",
186 249
       selectItems: [{ text: "password", value: 0 }],
187
-      selectErrors: "Some error with the field",
188
-      select: null,
189
-      textErrors: "Some error with the field",
190
-      text: "",
191
-      showPassword: false
250
+      boolMessage: false,
251
+      boolValidationError: false,
252
+      showPassword: false,
253
+      agencyNameLoad: false,
254
+      agencyNumberLoad: false,
255
+      companyRegNumberLoad: false,
256
+      agencyAdminNameLoad: false,
257
+      agencySurnameLoad: false,
258
+      agencyEmailLoad: false,
259
+      agencyCellNumberLoad: false,
260
+      agencyusernameLoad: false,
261
+      agencypasswordLoad: false,
262
+      agencyconfirmLoad: false,
263
+      errorOccurred: "",
264
+      errorMessage: ""
192 265
     };
193 266
   },
194 267
   computed: {
195
-    ...mapState("register", ["registerAgency"])
268
+    ...mapState("register", ["registerAgency"]),
269
+    Header() {
270
+      return this.RegisterHeader ? "Agency Administrator Details" : "Private Individual";
271
+    }
196 272
   },
197 273
   methods: {
198 274
     ...mapActions("register", ["getAgency", "saveAgency", "updateAgency", "clearAgency"]),
@@ -201,10 +277,6 @@ export default {
201 277
         this.$router.push("/user/login");
202 278
       }
203 279
     },
204
-    routerGoTo(goTo) {
205
-      this.$emit("routerGoTo", goTo);
206
-    },
207
-
208 280
     togglePassword() {
209 281
       this.showPassword = true;
210 282
       this.isPasswordShown = "text";
@@ -214,21 +286,92 @@ export default {
214 286
       this.isPasswordShown = "password";
215 287
     },
216 288
     SubmitData() {
217
-      this.saveAgency(this.registerAgency).then(() => {
218
-        console.log(Log.getUser().role);
219
-        setTimeout(() => {
220
-          if (Log.getUser().role !== "Super Admin") {
221
-            this.$router.push("/user/login");
222
-          } else {
223
-            this.$refs.dataToggle.click();
224
-            this.$router.go();
289
+      this.boolValidationError = false;
290
+      this.boolMessage = false;
291
+      if(this.validatePage()){
292
+        this.saveAgency(this.registerAgency)
293
+        .then(() => {
294
+          this.boolMessage = true;
295
+          console.log('registerAgency true');
296
+          console.log(Log.getUser().role);
297
+          setTimeout(() => {
298
+            if (Log.getUser().role !== "Super Admin") {
299
+              this.$router.push("/user/login");
300
+            } else {
301
+              this.$refs.dataToggle.click();
302
+              this.$router.go();
303
+            }
304
+          }, 500);
305
+        })
306
+        .catch(err => {
307
+          this.boolValidationError = true;
308
+          this.errorOccurred = "ERROR";
309
+          this.errorMessage = "Server Error: CONNECTION_REFUSED"; 
310
+
311
+          if (err) {
312
+            if (err.data.message) {
313
+              this.errorMessage = err.data.message;
314
+            } else {
315
+              this.errorMessage = "Error."
316
+            }
225 317
           }
226
-        }, 500);
227
-      });
228
-      //this.$router.push("/user/login");
318
+        });
319
+      }
229 320
     },
230 321
     Close() {
231 322
       this.$router.push("/user/login");
323
+    },
324
+    validatePage : function(){
325
+      console.log('validatePage');
326
+      if (this.registerAgency.name && this.registerAgency.eaabeffcNumber &&  this.registerAgency.companyRegNumber 
327
+         && this.registerAgency.user.name && this.registerAgency.user.surname && this.registerAgency.user.email 
328
+         && this.registerAgency.user.cellNumber && this.registerAgency.user.username && this.registerAgency.user.password
329
+         && this.registerAgency.user.password === this.registerAgency.user.confirm){
330
+        console.log('passed');
331
+        this.errorOccurred = '';
332
+        this.errorMessage = '';
333
+        this.boolValidationError = true;
334
+        return true;
335
+      } else {
336
+        console.log('failed');
337
+        this.boolValidationError = true;
338
+        this.agencyNameLoad = true,
339
+        this.agencyNumberLoad = true,
340
+        this.companyRegNumberLoad = true,
341
+        this.agencyAdminNameLoad = true,
342
+        this.agencySurnameLoad = true,
343
+        this.agencyEmailLoad = true,
344
+        this.agencyCellNumberLoad= true,
345
+        this.agencyusernameLoad = true,
346
+        this.agencypasswordLoad = true,
347
+        this.agencyconfirmLoad = true,
348
+        this.errorOccurred = "ERROR";
349
+        this.errorMessage = "Please check form and correct all input fields!";
350
+        return false;
351
+      }
352
+    },
353
+    requiredField : function(tfield) {
354
+      if(tfield){
355
+        return true;
356
+      } else {
357
+        return false;
358
+      }
359
+    },
360
+    validEmail : function(email) {
361
+        var re = /(.+)@(.+){2,}\.(.+){2,}/;
362
+        return re.test(email.toLowerCase());
363
+    },
364
+    validConfirm : function(tfield) {
365
+      //console.log(tfield);
366
+      if (this.requiredField(tfield)){
367
+        if(tfield === this.registerAgency.user.password){
368
+          return true;
369
+        } else {
370
+          return false;
371
+        } 
372
+      } else {
373
+        return false;
374
+      }
232 375
     }
233 376
   }
234 377
 };

+ 27
- 40
src/components/user/registerIndividual.vue Visa fil

@@ -6,17 +6,13 @@
6 6
           <alert :text="'Register Success! You\'ll be redirected shortly.'" :type="'SUCCESS'" />
7 7
         </div>
8 8
       </div>
9
-      <div v-if="boolUserExists" class="row">
10
-        <div class="col">
11
-          <alert :text="'This username is already in use'" :type="'ERROR'" />
12
-        </div>
13
-      </div>
14 9
       <div v-if="boolValidationError" class="row">
15 10
         <div class="col">
16 11
           <alert :text="errorMessage" :type="errorOccurred" />
17 12
         </div>
18 13
       </div>
19
-      <div class="row needs-validation">
14
+      <h3 class="card-title text-center">User Details</h3>
15
+      <div class="row">
20 16
         <div class="col-sm-12 col-md-6 ">
21 17
           <div class="form-group">
22 18
             <b-form-input
@@ -33,7 +29,7 @@
33 29
             <div class="invalid-feedback">Name is required!</div>
34 30
           </div>
35 31
           <div class="form-group">
36
-            <b-form-input
32
+            <input
37 33
               type="text"
38 34
               id="inputSurname"
39 35
               class="form-control uniInput my-2"
@@ -82,9 +78,9 @@
82 78
             id="inputTelephone"
83 79
             v-model="indivUser.telephone"
84 80
             class="form-control uniInput my-2"
81
+            v-bind:class="{'is-valid': indivUser.telephone}"
85 82
             placeholder="Landline Number"
86 83
           />
87
-          <div class="invalid-feedback">Landline number is required!</div>
88 84
         </div>
89 85
       </div>
90 86
       <hr />
@@ -139,8 +135,12 @@
139 135
           <label for="tc"
140 136
             ><router-link to="/termsConditionsView">Terms & Conditions</router-link></label
141 137
           >
142
-
143
-          <input name="tc" type="checkbox" class="ml-3 mt-2" v-model="terms" />
138
+          <input
139
+            name="tc"
140
+            type="checkbox"
141
+            class="ml-3 mt-2"
142
+            v-model="terms"
143
+            />
144 144
         </div>
145 145
       </div>
146 146
       <button
@@ -185,10 +185,6 @@ export default {
185 185
     return {
186 186
       isPasswordShown: "password",
187 187
       selectItems: [{ text: "password", value: 0 }],
188
-      selectErrors: "Some error with the field",
189
-      select: undefined,
190
-      textErrors: "Some error with the field",
191
-      text: "",
192 188
       showPassword: false,
193 189
       boolMessage: false,
194 190
       terms: false,
@@ -202,7 +198,6 @@ export default {
202 198
         password: '',
203 199
         confirmPassword: ''
204 200
       },
205
-      boolUserExists: false,
206 201
       boolValidationError: false,
207 202
       nameLoad: false,
208 203
       surnameLoad: false,
@@ -213,17 +208,13 @@ export default {
213 208
       passwordLoad: false,
214 209
       confirmPasswordLoad: false,
215 210
       errorOccurred: "",
216
-      errorMessage: "",
217
-      valid: false
211
+      errorMessage: ""
218 212
     };
219 213
   },
220 214
   computed: {
221 215
     ...mapState("register", ["registerIndividual"]),
222 216
     Header() {
223 217
       return this.RegisterHeader ? "Agency Administrator Details" : "Private Individual";
224
-    },
225
-    isDisabled: function() {
226
-      return !this.terms;
227 218
     }
228 219
   },
229 220
   methods: {
@@ -248,10 +239,7 @@ export default {
248 239
     },
249 240
     SubmitData() {
250 241
       this.indivUser.acceptedTerms = this.terms;
251
-      console.log(this.indivUser.email);
252 242
       if (this.validatePage()) {
253
-        console.log(this.indivUser.username);
254
-        if (this.indivUser.username) {
255 243
           this.saveIndividual(this.indivUser)
256 244
             .then(res => {
257 245
               this.boolMessage = true;
@@ -265,17 +253,19 @@ export default {
265 253
               }, 500);
266 254
             })
267 255
             .catch(err => {
268
-              console.log(err.message);
269
-              this.boolUserExists = true;
270
-            });
271
-        } else {
272
-          this.validationErrorMessage = "Username Required";
273
-          this.boolValidationError = true;
274
-        }
275
-      } else {
276
-        this.validationErrorMessage = "Email Required";
277
-        this.boolValidationError = true;
278
-      }
256
+              console.log(err);
257
+              this.boolValidationError = true;
258
+              this.errorOccurred = "ERROR";
259
+              this.errorMessage = "Server Error: CONNECTION_REFUSED"; 
260
+              if (err) {
261
+                if (err.data.message) {
262
+                  this.errorMessage = err.data.message;
263
+                } else {
264
+                  this.errorMessage = "Error."
265
+                }
266
+              }
267
+            }); 
268
+      } 
279 269
     },
280 270
     Close() {
281 271
       this.$router.push("/user/login");
@@ -283,14 +273,14 @@ export default {
283 273
     validatePage : function(){
284 274
       console.log('validatePage')
285 275
       if (this.indivUser.name && this.indivUser.surname && this.indivUser.email 
286
-         && this.indivUser.cellNumber && this.indivUser.telephone && this.indivUser.username && this.indivUser.password
276
+         && this.indivUser.cellNumber && this.indivUser.username && this.indivUser.password
287 277
          && this.indivUser.password === this.indivUser.confirmPassword){
288 278
         this.errorOccurred = '';
289 279
         this.errorMessage = '';
290
-        this.valid = true;
280
+        this.boolValidationError = false;
291 281
         return true;
292 282
       } else {
293
-        this.valid = false;
283
+        this.boolValidationError = true;
294 284
         this.nameLoad = true,
295 285
         this.surnameLoad = true,
296 286
         this.emailLoad = true,
@@ -316,10 +306,7 @@ export default {
316 306
         return re.test(email.toLowerCase());
317 307
     },
318 308
     validConfirm : function(tfield) {
319
-      console.log(tfield);
320 309
       if (this.requiredField(tfield)){
321
-        console.log(tfield);
322
-        console.log(this.indivUser.password);
323 310
         if(tfield === this.indivUser.password){
324 311
           return true;
325 312
         } else {

+ 1
- 20
src/components/user/registerPage.vue Visa fil

@@ -74,16 +74,12 @@ export default {
74 74
   props: {
75 75
     RegisterHeader: { type: String, default: undefined }
76 76
   },
77
-  name: "PrivateIndividual",
77
+  name: "RegisterPage",
78 78
   data() {
79 79
     return {
80 80
       user: undefined,
81 81
       isPasswordShown: "password",
82 82
       selectItems: [{ text: "password", value: 0 }],
83
-      selectErrors: "Some error with the field",
84
-      select: undefined,
85
-      textErrors: "Some error with the field",
86
-      text: "",
87 83
       showPassword: false
88 84
     };
89 85
   },
@@ -95,12 +91,6 @@ export default {
95 91
     }
96 92
   },
97 93
   methods: {
98
-    ...mapActions("register", [
99
-      "getIndividual",
100
-      "saveIndividual",
101
-      "updateIndividual",
102
-      "clearIndividual"
103
-    ]),
104 94
     togglePassword() {
105 95
       this.showPassword = true;
106 96
       this.isPasswordShown = "text";
@@ -109,15 +99,6 @@ export default {
109 99
       this.showPassword = false;
110 100
       this.isPasswordShown = "password";
111 101
     },
112
-    SubmitData() {
113
-      this.saveIndividual(this.registerIndividual)
114
-        .then(() => {
115
-          this.$router.push("/user/login");
116
-        })
117
-        .catch(ex => {
118
-          //console.log(ex);
119
-        });
120
-    },
121 102
     Close() {
122 103
       if (Log.getUser().role !== "Super Admin") {
123 104
         this.$router.push("/user/login");

+ 2
- 3
src/main.js Visa fil

@@ -39,7 +39,7 @@ Vue.use(IconsPlugin)
39 39
 
40 40
 Vue.use(VueGoogleMaps, {
41 41
         load: {
42
-            key: 'AIzaSyD8k_Kwml_C8IDfs-gX8JFV8acli3L9cAE',
42
+            key: 'AIzaSyBpubKVyM2HwrJreGsENtKbWd38AhNTC0w',
43 43
             libraries: 'places,directions', // This is required if you use the Autocomplete plugin
44 44
             // OR: libraries: 'places,drawing'
45 45
             // OR: libraries: 'places,drawing,visualization'
@@ -58,8 +58,7 @@ Vue.use(VueAnalytics, {
58 58
 Vue.config.productionTip = false
59 59
 axios.defaults.baseURL = 'http://localhost:57260'
60 60
     //axios.defaults.baseURL = "https://www.pvsl.co.za:86/";
61
-    //axios.defaults.baseURL = "http://training.provision-sa.com:120/";
62
-    //axios.defaults.baseURL = "http://localhost:8080/"
61
+    //axios.defaults.baseURL = "http://training.provision-sa.com:120/"
63 62
 
64 63
 Vue.prototype.$axios = axios
65 64
 const pluginOptions = {

+ 267
- 260
src/store/modules/timeshare/timeshare.js Visa fil

@@ -1,273 +1,280 @@
1 1
 /* eslint-disable guard-for-in */
2 2
 /* eslint-disable no-restricted-syntax */
3 3
 /* eslint-disable */
4
-import axios from "axios";
5
-import _ from "lodash";
6
-import MyData from "../../../assets/myData";
7
-import MaritalStatus from "../../../assets/staticData/maritalStatus";
4
+import axios from 'axios'
5
+import _ from 'lodash'
6
+import MyData from '../../../assets/myData'
7
+import MaritalStatus from '../../../assets/staticData/maritalStatus'
8 8
 
9 9
 export default {
10
-  namespaced: true,
11
-  state: {
12
-    resorts: [],
13
-    regions: [],
14
-    detailedRegion: [],
15
-    seasons: [],
16
-    resortBedrooms: [],
17
-    maxSleep: [],
18
-    bankedEntities: [],
19
-    agencies: [],
20
-    agents: [],
21
-    timeshareFilter: "",
22
-    maritalStatus: MaritalStatus,
23
-    result: undefined,
24
-    latestWeeks: [],
25
-    sellItem: {
26
-      referedByAgent: false,
27
-      agentId: undefined,
28
-      agencyId: undefined,
29
-      otherResort: false,
30
-      otherResortName: undefined,
31
-      resort: undefined,
32
-      resortCode: undefined,
33
-      resortName: undefined,
34
-      regionId: undefined,
35
-      season: undefined,
36
-      module: undefined,
37
-      unitNumber: undefined,
38
-      bedrooms: undefined,
39
-      maxSleep: undefined,
40
-      weekNumber: undefined,
41
-      levyAmount: undefined,
42
-      currentYearBanked: false,
43
-      bankedWith: undefined,
44
-      leviesPaidInFull: false,
45
-      weekPlacedForRental: false,
46
-      originalPurchasePrice: undefined,
47
-      originalPurchaseDate: undefined,
48
-      arrivalDate: undefined,
49
-      departureDate: undefined,
50
-      sellPrice: undefined,
51
-      agentCommission: undefined,
52
-      mandate: undefined,
53
-      status: undefined,
54
-      owner: {
55
-        address: {},
56
-        bankingDetails: {}
57
-      }
58
-    }
59
-  },
60
-  mutations: {
61
-    setUnitConfigurationList(state, list) {
62
-      state.unitConfigurationList = list;
10
+    namespaced: true,
11
+    state: {
12
+        resorts: [],
13
+        regions: [],
14
+        detailedRegion: [],
15
+        seasons: [],
16
+        resortBedrooms: [],
17
+        maxSleep: [],
18
+        bankedEntities: [],
19
+        agencies: [],
20
+        agents: [],
21
+        timeshareFilter: '',
22
+        maritalStatus: MaritalStatus,
23
+        result: undefined,
24
+        latestWeeks: [],
25
+        sellItem: {
26
+            referedByAgent: false,
27
+            agentId: undefined,
28
+            agencyId: undefined,
29
+            otherResort: false,
30
+            otherResortName: undefined,
31
+            resort: undefined,
32
+            resortCode: undefined,
33
+            resortName: undefined,
34
+            regionId: undefined,
35
+            season: undefined,
36
+            module: undefined,
37
+            unitNumber: undefined,
38
+            bedrooms: undefined,
39
+            maxSleep: undefined,
40
+            weekNumber: undefined,
41
+            levyAmount: undefined,
42
+            currentYearBanked: false,
43
+            bankedWith: undefined,
44
+            leviesPaidInFull: false,
45
+            weekPlacedForRental: false,
46
+            originalPurchasePrice: undefined,
47
+            originalPurchaseDate: undefined,
48
+            arrivalDate: undefined,
49
+            departureDate: undefined,
50
+            sellPrice: undefined,
51
+            agentCommission: undefined,
52
+            mandate: undefined,
53
+            status: undefined,
54
+            owner: {
55
+                address: {},
56
+                bankingDetails: {},
57
+            },
58
+        },
63 59
     },
64
-    filterStore(state, input){
65
-      state.timeshareFilter = input
66
-    },
67
-    setAgency(state, agencies) {
68
-      state.agencies = agencies;
69
-    },
70
-    setAgent(state, agents) {
71
-      state.agents = agents;
72
-    },
73
-    setSeason(state, seasons) {
74
-      state.seasons = seasons;
75
-    },
76
-    setResortBedrooms(state, resortBedrooms) {
77
-      state.resortBedrooms = resortBedrooms;
78
-    },
79
-    setMaxSleep(state, maxSleep) {
80
-      state.maxSleep = maxSleep;
81
-    },
82
-    setBankedEntities(state, bankedEntities) {
83
-      state.bankedEntities = bankedEntities;
84
-    },
85
-    addResort(state, resorts) {
86
-      state.resorts = resorts;
87
-    },
88
-    addRegion(state, regions) {
89
-      state.regions = regions;
90
-    },
91
-    addDetailedRegion(state, detailedRegion) {
92
-      state.detailedRegion.push(detailedRegion);
93
-    },
94
-    changeResort(state, resort) {
95
-      for (const reg in state.detailedRegion) {
96
-        const region = state.detailedRegion[reg];
97
-        if (_.find(region.children, x => x.resortCode === resort.resortCode)) {
98
-          state.regionId = reg;
99
-          break;
100
-        }
101
-      }
102
-      state.sellItem.resortCode = resort.resortCode;
103
-      state.sellItem.resortName = resort.resortName;
104
-    },
105
-    displayResult(state) {
106
-      state.result = "Week has been added ^-^";
107
-    },
108
-    setWeekDetail(state, week) {
109
-      state.sellItem = week;
110
-    },
111
-    agentUpdate(state, agent) {
112
-      var index
113
-      var count = 0
114
-      state.agents.forEach((item) => {
115
-        if (item.id === agent.id) {
116
-          index = count
117
-        }
118
-        count++
119
-      })
120
-      Object.assign(state.agents[index], agent)
121
-    },
122
-    getLatestWeeks(state, data){
123
-      state.latestWeeks = data
124
-    }
125
-  },
126
-  getters: {
127
-    getRegionCode(state) {
128
-      return value => {
129
-        const reg = state.detailedRegion.find(region =>
130
-          region.children.some(resort => resort.resortCode === value)
131
-        );
132
-        if (reg && reg.region) {
133
-          return reg.region.regionCode;
134
-        }
135
-        return "";
136
-      };
137
-    },
138
-    getResortName(state) {
139
-      return value => {
140
-        const res = state.resorts.find(resort => resort.resortCode === value);
141
-        if (res) {
142
-          return res.resortName;
143
-        }
144
-      };
145
-    },
146
-    getLatestWeeks: (state) => state.latestWeeks
147
-  },
148
-  actions: {
149
-    initTimeshare({ commit, dispatch }, timeshareId) {
150
-      commit("setResortBedrooms", MyData.resortBedrooms);
151
-      commit("setMaxSleep", MyData.maxBedrooms);
152
-      commit("setBankedEntities", MyData.bankedEntities);
153
-      dispatch("getSeasons");
154
-      dispatch("getAgents");
155
-      dispatch("getAgencies");
156
-      dispatch("getResorts");
157
-      dispatch("getRegions");
158
-      if (timeshareId && timeshareId !== 0) {
159
-        dispatch("getWeekDetail", timeshareId);
160
-      }
161
-    },
162
-    updateFilter({commit}, input){
163
-      commit('filterStore', input)
164
-    },
165
-    getWeekDetail({ commit }, timeshareId) {
166
-      axios
167
-        .get(`api/timeshareweek/${timeshareId}`)
168
-        .then(result => {
169
-          commit("setWeekDetail", result.data);
170
-        })
171
-        .catch(console.error);
172
-    },
173
-    getSeasons({ commit }) {
174
-      axios
175
-        .get("/api/season")
176
-        .then(result => commit("setSeason", result.data))
177
-        .catch(console.error);
178
-    },
179
-    getAgencies({ commit }) {
180
-      axios
181
-        .get("/api/agency")
182
-        .then(result => commit("setAgency", result.data))
183
-        .catch(console.error);
184
-    },
185
-    getAgents({ commit }) {
186
-      axios
187
-        .get("/api/agent")
188
-        .then(result => commit("setAgent", result.data))
189
-        .catch(console.error);
190
-    },
191
-    getResorts({ commit }) {
192
-      axios
193
-        .get("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/list/")
194
-        .then(result => {commit("addResort", result.data)
195
-        console.log(result.data);
196
-      })
197
-        .catch(console.error);
60
+    mutations: {
61
+        setUnitConfigurationList(state, list) {
62
+            state.unitConfigurationList = list
63
+        },
64
+        filterStore(state, input) {
65
+            state.timeshareFilter = input
66
+        },
67
+        setAgency(state, agencies) {
68
+            state.agencies = agencies
69
+        },
70
+        setAgent(state, agents) {
71
+            state.agents = agents
72
+        },
73
+        setSeason(state, seasons) {
74
+            state.seasons = seasons
75
+        },
76
+        setResortBedrooms(state, resortBedrooms) {
77
+            state.resortBedrooms = resortBedrooms
78
+        },
79
+        setMaxSleep(state, maxSleep) {
80
+            state.maxSleep = maxSleep
81
+        },
82
+        setBankedEntities(state, bankedEntities) {
83
+            state.bankedEntities = bankedEntities
84
+        },
85
+        addResort(state, resorts) {
86
+            state.resorts = resorts
87
+        },
88
+        addRegion(state, regions) {
89
+            state.regions = regions
90
+        },
91
+        addDetailedRegion(state, detailedRegion) {
92
+            state.detailedRegion.push(detailedRegion)
93
+        },
94
+        changeResort(state, resort) {
95
+            for (const reg in state.detailedRegion) {
96
+                const region = state.detailedRegion[reg]
97
+                if (
98
+                    _.find(region.children, (x) => x.resortCode === resort.resortCode)
99
+                ) {
100
+                    state.regionId = reg
101
+                    break
102
+                }
103
+            }
104
+            state.sellItem.resortCode = resort.resortCode
105
+            state.sellItem.resortName = resort.resortName
106
+        },
107
+        displayResult(state) {
108
+            state.result = 'Week has been added ^-^'
109
+        },
110
+        setWeekDetail(state, week) {
111
+            state.sellItem = week
112
+        },
113
+        agentUpdate(state, agent) {
114
+            var index
115
+            var count = 0
116
+            state.agents.forEach((item) => {
117
+                if (item.id === agent.id) {
118
+                    index = count
119
+                }
120
+                count++
121
+            })
122
+            Object.assign(state.agents[index], agent)
123
+        },
124
+        getLatestWeeks(state, data) {
125
+            state.latestWeeks = data
126
+        },
198 127
     },
199
-    getRegions({ dispatch, commit }) {
200
-      axios
201
-        .get("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/regions/list/ZA")
202
-        .then(result => {
203
-          commit("addRegion", result.data);
204
-          dispatch("getDetailedRegion", result.data);
205
-        })
206
-        .catch(console.error);
128
+    getters: {
129
+        getRegionCode(state) {
130
+            return (value) => {
131
+                const reg = state.detailedRegion.find((region) =>
132
+                    region.children.some((resort) => resort.resortCode === value),
133
+                )
134
+                if (reg && reg.region) {
135
+                    return reg.region.regionCode
136
+                }
137
+                return ''
138
+            }
139
+        },
140
+        getResortName(state) {
141
+            return (value) => {
142
+                const res = state.resorts.find((resort) => resort.resortCode === value)
143
+                if (res) {
144
+                    return res.resortName
145
+                }
146
+            }
147
+        },
148
+        getLatestWeeks: (state) => state.latestWeeks,
207 149
     },
208
-    getDetailedRegion({ commit }, data) {
209
-      if (data) {
210
-        for (const r in Object.keys(data)) {
211
-          const region = data[r];
212
-          if (region !== undefined) {
150
+    actions: {
151
+        initTimeshare({ commit, dispatch }, timeshareId) {
152
+            commit('setResortBedrooms', MyData.resortBedrooms)
153
+            commit('setMaxSleep', MyData.maxBedrooms)
154
+            commit('setBankedEntities', MyData.bankedEntities)
155
+            dispatch('getSeasons')
156
+            dispatch('getAgents')
157
+            dispatch('getAgencies')
158
+            dispatch('getResorts')
159
+            dispatch('getRegions')
160
+            if (timeshareId && timeshareId !== 0) {
161
+                dispatch('getWeekDetail', timeshareId)
162
+            }
163
+        },
164
+        updateFilter({ commit }, input) {
165
+            commit('filterStore', input)
166
+        },
167
+        getWeekDetail({ commit }, timeshareId) {
213 168
             axios
214
-              .get(
215
-                `https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/${region.regionCode}/`
216
-              )
217
-              .then(result =>
218
-                commit("addDetailedRegion", {
219
-                  region,
220
-                  children: result.data
169
+                .get(`api/timeshareweek/${timeshareId}`)
170
+                .then((result) => {
171
+                    commit('setWeekDetail', result.data)
221 172
                 })
222
-              )
223
-              .catch(console.error);
224
-          }
225
-        }
226
-      }
227
-    },
228
-    async retrieveLatestWeeks({commit}){
229
-      await axios.get('/api/timeshareWeek/GetLatest')
230
-      .then((result) => {
231
-        commit('getLatestWeeks', result.data)
232
-      })
233
-    },
234
-    onResortChange({ commit }, resort) {
235
-      commit("changeResort", resort);
236
-    },
237
-    async saveWeek({ commit }, week) {
238
-      return await new Promise((resolve, reject) => {
239
-        axios
240
-          .post("/api/timeshareweek", week)
241
-          .then(result => {
242
-            commit("setWeekDetail", result.data);
243
-            resolve(result.data);
244
-          })
245
-          .catch(error => {
246
-            if(error.response){
247
-              reject(error.response)
173
+                .catch(console.error)
174
+        },
175
+        getSeasons({ commit }) {
176
+            axios
177
+                .get('/api/season')
178
+                .then((result) => commit('setSeason', result.data))
179
+                .catch(console.error)
180
+        },
181
+        getAgencies({ commit }) {
182
+            axios
183
+                .get('/api/agency')
184
+                .then((result) => commit('setAgency', result.data))
185
+                .catch(console.error)
186
+        },
187
+        getAgents({ commit }) {
188
+            axios
189
+                .get('/api/agent')
190
+                .then((result) => commit('setAgent', result.data))
191
+                .catch(console.error)
192
+        },
193
+        getResorts({ commit }) {
194
+            axios
195
+                .get(
196
+                    'https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/list/',
197
+                )
198
+                .then((result) => {
199
+                    commit('addResort', result.data)
200
+                    console.log(result.data)
201
+                })
202
+                .catch(console.error)
203
+        },
204
+        getRegions({ dispatch, commit }) {
205
+            axios
206
+                .get(
207
+                    'https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/regions/list/ZA',
208
+                )
209
+                .then((result) => {
210
+                    commit('addRegion', result.data)
211
+                    dispatch('getDetailedRegion', result.data)
212
+                })
213
+                .catch(console.error)
214
+        },
215
+        getDetailedRegion({ commit }, data) {
216
+            if (data) {
217
+                for (const r in Object.keys(data)) {
218
+                    const region = data[r]
219
+                    if (region !== undefined) {
220
+                        axios
221
+                            .get(
222
+                                `https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/${region.regionCode}?disabled=true`,
223
+                            )
224
+                            .then((result) =>
225
+                                commit('addDetailedRegion', {
226
+                                    region,
227
+                                    children: result.data,
228
+                                }),
229
+                            )
230
+                            .catch(console.error)
231
+                    }
232
+                }
248 233
             }
249
-          });
250
-      });
234
+        },
235
+        async retrieveLatestWeeks({ commit }) {
236
+            await axios.get('/api/timeshareWeek/GetLatest').then((result) => {
237
+                commit('getLatestWeeks', result.data)
238
+            })
239
+        },
240
+        onResortChange({ commit }, resort) {
241
+            commit('changeResort', resort)
242
+        },
243
+        async saveWeek({ commit }, week) {
244
+            return await new Promise((resolve, reject) => {
245
+                axios
246
+                    .post('/api/timeshareweek', week)
247
+                    .then((result) => {
248
+                        commit('setWeekDetail', result.data)
249
+                        resolve(result.data)
250
+                    })
251
+                    .catch((error) => {
252
+                        if (error.response) {
253
+                            reject(error.response)
254
+                        }
255
+                    })
256
+            })
251 257
 
252
-      // axios
253
-      //   .post('/api/timeshareweek', week)
254
-      //   .then(result => commit('displayResult'))
255
-      //   .catch(console.error);
256
-    },
257
-    getBlankWeek({ commit }) {
258
-      axios
259
-        .get("/api/timeshareweek/gettemplate")
260
-        .then(result => commit("setWeekDetail", result.data))
261
-        .catch(console.error);
258
+            // axios
259
+            //   .post('/api/timeshareweek', week)
260
+            //   .then(result => commit('displayResult'))
261
+            //   .catch(console.error);
262
+        },
263
+        getBlankWeek({ commit }) {
264
+            axios
265
+                .get('/api/timeshareweek/gettemplate')
266
+                .then((result) => commit('setWeekDetail', result.data))
267
+                .catch(console.error)
268
+        },
269
+        async updateAgent({ commit }, agent) {
270
+            await axios
271
+                .put('/api/agent', agent)
272
+                .then((result) => {
273
+                    commit('agentUpdate', result.data)
274
+                })
275
+                .catch((ex) => {
276
+                    console.log(ex)
277
+                })
278
+        },
262 279
     },
263
-    async updateAgent({commit}, agent){
264
-      await axios.put("/api/agent", agent)
265
-      .then((result) => {
266
-        commit("agentUpdate", result.data)
267
-      })
268
-      .catch((ex) => {
269
-        console.log(ex);
270
-      })
271
-    }
272
-  }
273
-};
280
+}

+ 16
- 11
src/store/modules/user/register.js Visa fil

@@ -30,6 +30,7 @@ export default {
30 30
                 telephone: '',
31 31
                 username: '',
32 32
                 password: '',
33
+                confirm: '',
33 34
                 role: '',
34 35
             },
35 36
         },
@@ -95,6 +96,7 @@ export default {
95 96
                     cellNumber: '',
96 97
                     username: '',
97 98
                     password: '',
99
+                    confirm: '',
98 100
                 },
99 101
             }
100 102
         },
@@ -122,12 +124,6 @@ export default {
122 124
                     console.log(ex.response)
123 125
                     return Promise.reject(ex.response)
124 126
                 })
125
-                // if(response.status === 200){
126
-                //   return Promise.resolve()
127
-                // }else{
128
-                //   console.log(response.response);
129
-                //   return Promise.reject()
130
-                // }
131 127
         },
132 128
         getIndividuals({ commit }) {
133 129
             axios
@@ -167,16 +163,25 @@ export default {
167 163
                     return promise.resolve()
168 164
                 })
169 165
                 .catch((ex) => {
170
-                    console.log(ex.response)
166
+                    //console.log(ex.response)
171 167
                     return promise.reject(ex.response)
172 168
                         //console.error;
173 169
                 })
174 170
         },
175
-        saveAgency({ commit }, item) {
176
-            axios
171
+        async saveAgency({ commit }, item) {
172
+            await axios
177 173
                 .post('/api/register/registeragency', item)
178
-                .then((result) => commit('addAgency', result.data))
179
-                .catch((ex) => console.log(ex.response))
174
+                .then((res) => {
175
+                    commit('addAgency', res.data)
176
+                    console.log(promise.resolve())
177
+                    console.log('Agency Added')
178
+                    return promise.resolve()
179
+                })
180
+                .catch((ex) => {
181
+                    console.log('regAgency API failed')
182
+                        //console.log(ex.response)
183
+                    return promise.reject(ex.response)
184
+                })
180 185
         },
181 186
         async saveAgent({ commit }, item) {
182 187
             await axios

Laddar…
Avbryt
Spara