Explorar el Código

Fix UpdateInfo on Agent/Agency

master
Brian Conway hace 2 años
padre
commit
46164eec3e

+ 1
- 0
public/googlea6e63bc009bf908f_2022-09-06 021026 PM.html Ver fichero

@@ -0,0 +1 @@
1
+google-site-verification: googlea6e63bc009bf908f.html

+ 9
- 9
src/components/user/registerIndividual.vue Ver fichero

@@ -347,15 +347,15 @@ export default {
347 347
         return true
348 348
       } else {
349 349
         this.boolValidationError = true
350
-        ;(this.nameLoad = true),
351
-          (this.surnameLoad = true),
352
-          (this.emailLoad = true),
353
-          (this.cellNumberLoad = true),
354
-          (this.telephoneLoad = true),
355
-          (this.usernameLoad = true),
356
-          (this.passwordLoad = true),
357
-          (this.confirmPasswordLoad = true),
358
-          (this.errorOccurred = 'ERROR')
350
+        this.nameLoad = true
351
+        this.surnameLoad = true
352
+        this.emailLoad = true
353
+        this.cellNumberLoad = true
354
+        this.telephoneLoad = true
355
+        this.usernameLoad = true
356
+        this.passwordLoad = true
357
+        this.confirmPasswordLoad = true
358
+        this.errorOccurred = 'ERROR'
359 359
         this.errorMessage = 'Please check form and correct all input fields!'
360 360
         return false
361 361
       }

+ 321
- 165
src/components/user/updateAgentProfile.vue Ver fichero

@@ -5,194 +5,240 @@
5 5
         <div class="form">
6 6
           <div class="row">
7 7
             <div class="section-header">
8
-              <h2>Update Agent Info</h2>
8
+              <h2>update agent info</h2>
9 9
             </div>
10 10
           </div>
11
-          <div class="row">
12
-            <div class="col">
13
-              <float-label>
11
+          <div class="row mb-4">
12
+            <div class="col-md-6">
13
+              <float-label fixed label="username">
14 14
                 <input
15 15
                   type="text"
16
-                  name="name"
17
-                  class="form-control uniInput"
18
-                  id="name"
19
-                  placeholder="USERNAME"
16
+                  name="username"
17
+                  class="form-control uniinput"
18
+                  id="username"
19
+                  placeholder="name"
20 20
                   data-rule="minlen:4"
21
-                  data-msg="Please enter your name"
21
+                  data-msg="please enter your name"
22 22
                   v-model="agent.user.username"
23
+                  v-bind:class="{
24
+                    'is-valid': agent.user.username,
25
+                    'is-invalid':
26
+                      !requiredfield(agent.user.username) && usernameload,
27
+                  }"
28
+                  v-on:keyup="usernameLoad = true"
29
+                  v-on:blur="usernameLoad = true"
23 30
                 />
31
+                <div class="invalid-feedback">Username is Required!</div>
24 32
               </float-label>
25 33
             </div>
26
-            <div class="col">
34
+            <div class="form-group col-md-6">
27 35
               <float-label>
28 36
                 <input
29 37
                   type="text"
30 38
                   name="name"
31 39
                   class="form-control uniInput"
32 40
                   id="name"
33
-                  placeholder="NAME"
41
+                  placeholder="Name"
34 42
                   data-rule="minlen:4"
35 43
                   data-msg="Please enter your name"
36 44
                   v-model="agent.name"
45
+                  v-bind:class="{
46
+                    'is-valid': agent.name,
47
+                    'is-invalid': !requiredField(agent.name) && nameLoad,
48
+                  }"
49
+                  v-on:keyup="nameLoad = true"
50
+                  v-on:blur="nameLoad = true"
37 51
                 />
52
+                <div class="invalid-feedback">Name is Required!</div>
38 53
               </float-label>
39 54
             </div>
40 55
           </div>
41 56
           <div class="row mt-4">
42
-            <div class="col-md-6">
57
+            <div class="form-group col-md-6">
43 58
               <float-label>
44 59
                 <input
45 60
                   type="text"
46 61
                   class="form-control uniInput"
47 62
                   name="surname"
48 63
                   id="surname"
49
-                  placeholder="SURNAME"
64
+                  placeholder="Surname"
50 65
                   data-msg="Please enter your surname"
51 66
                   v-model="agent.surname"
67
+                  v-bind:class="{
68
+                    'is-valid': agent.surname,
69
+                    'is-invalid': !requiredField(agent.surname) && surnameLoad,
70
+                  }"
71
+                  v-on:keyup="surnameLoad = true"
72
+                  v-on:blur="surnameLoad = true"
52 73
                 />
74
+                <div class="invalid-feedback">Surname is Required!</div>
53 75
               </float-label>
54 76
             </div>
55
-            <div class="col">
77
+            <div class="form-group col-md-6">
56 78
               <float-label>
57 79
                 <input
58 80
                   type="text"
59 81
                   class="form-control uniInput"
60 82
                   name="email"
61 83
                   id="email"
62
-                  placeholder="EMAIL ADDRESS"
84
+                  placeholder="Email Address"
63 85
                   data-msg="Please enter your email address"
64 86
                   v-model="agent.email"
87
+                  v-bind:class="{
88
+                    'is-valid': agent.email,
89
+                    'is-invalid': !validEmail(agent.email) && emailAddressLoad,
90
+                  }"
91
+                  v-on:keyup="emailAddressLoad = true"
92
+                  v-on:blur="emailAddressLoad = true"
65 93
                 />
94
+                <div class="invalid-feedback">
95
+                  Valid Email address is Required!
96
+                </div>
66 97
               </float-label>
67 98
             </div>
68
-            <!-- <div class="col">
69
-            <float-label>
70
-              <input
71
-                type="text"
72
-                name="idnum"
73
-                class="form-control uniInput"
74
-                id="idnum"
75
-                placeholder="ID NUMBER"
76
-                data-rule="minlen:4"
77
-                data-msg="Please enter your ID number"
78
-              />
79
-            </float-label>
80
-          </div> -->
81
-          </div>
82
-          <!-- <div class="row mt-4">
83
-          <div class="col-md-6">
84
-            <float-label>
85
-              <input
86
-                type="text"
87
-                class="form-control uniInput"
88
-                name="company"
89
-                id="company"
90
-                placeholder="COMPANY REG NUMBER"
91
-                data-rule="minlen:4"
92
-                data-msg="Please enter your company reg number"
93
-              />
94
-            </float-label>
95 99
           </div>
96
-        </div> -->
97 100
           <div class="row mt-4">
98
-            <div class="col">
101
+            <div class="form-group col-md-6">
99 102
               <float-label>
100 103
                 <input
101 104
                   type="text"
102 105
                   name="cell"
103 106
                   class="form-control uniInput"
104 107
                   id="cell"
105
-                  placeholder="CELL NUMBER"
108
+                  placeholder="Cell Number"
106 109
                   data-rule="minlen:4"
107 110
                   data-msg="Please enter your cell number"
108 111
                   v-model="agent.cellNumber"
112
+                  v-bind:class="{
113
+                    'is-valid': agent.cellNumber,
114
+                    'is-invalid':
115
+                      validPhoneNumber(agent.cellNumber) &&
116
+                      !requiredField(agent.cellNumber) &&
117
+                      cellNumberLoad,
118
+                  }"
119
+                  v-on:keyup="cellNumberLoad = true"
120
+                  v-on:blur="cellNumberLoad = true"
109 121
                 />
122
+                <div class="invalid-feedback">
123
+                  Valid Cell Number is Required!
124
+                </div>
110 125
               </float-label>
111 126
             </div>
112
-            <div class="col">
127
+            <div class="form-group col-md-6">
113 128
               <float-label>
114 129
                 <input
115 130
                   type="text"
116 131
                   class="form-control uniInput"
117
-                  name="landline"
118
-                  id="landline"
119
-                  placeholder="TELEPHONE NUMBER"
132
+                  name="telephone"
133
+                  id="telephone"
134
+                  placeholder="Telephone Number"
120 135
                   data-msg="Please enter your Telephone number"
121 136
                   v-model="agent.telephone"
137
+                  v-bind:class="{
138
+                    'is-valid':
139
+                      agent.telephone && validPhoneNumber(agent.telephone),
140
+                    'is-invalid':
141
+                      agent.telephone && !validPhoneNumber(agent.telephone),
142
+                  }"
122 143
                 />
123
-              </float-label>
124
-            </div>
125
-          </div>
126
-          <div class="row mt-4">
127
-            <div class="col">
128
-              <float-label fixed label="AGENCY">
129
-                <select
130
-                  v-model="agent.agencyId"
131
-                  class="form-control uniSelect"
132
-                  name=""
133
-                  id=""
134
-                >
135
-                  <option
136
-                    v-for="agency in agencies"
137
-                    :key="agency.id"
138
-                    :value="agency.id"
139
-                  >
140
-                    {{ agency.agencyName }}
141
-                  </option>
142
-                </select>
143
-              </float-label>
144
-            </div>
145
-          </div>
146
-          <div v-if="pullUserRole === 'Super Admin'">
147
-            <div class="row">
148
-              <div class="col">
149
-                <div class="section-header">
150
-                  <h2>Access Control</h2>
144
+                <div class="invalid-feedback">
145
+                  Valid telephone number is required!!
151 146
                 </div>
152
-              </div>
147
+              </float-label>
153 148
             </div>
154
-            <div class="row">
149
+
150
+            <div class="row mt-4">
155 151
               <div class="col-md-6">
156
-                <float-label label="User Role" style="width: 100%;">
152
+                <float-label fixed label="Agency" style="width: 100%;">
157 153
                   <select
158 154
                     class="form-control uniSelect"
159
-                    id="howMarried"
160
-                    v-model="agent.user.role"
155
+                    v-model="agent.agencyId"
156
+                    v-bind:class="{
157
+                      'is-valid': agent.agencyId,
158
+                      'is-invalid':
159
+                        !requiredField(agent.agencyId) && inputAgencyLoad,
160
+                    }"
161
+                    v-on:keyup="inputAgencyLoad = true"
162
+                    v-on:blur="inputAgencyLoad = true"
161 163
                   >
164
+                    <option value="">Private User</option>
162 165
                     <option
163
-                      v-for="role in getRoles"
164
-                      :key="role.id"
165
-                      :value="role.roleName"
166
+                      v-for="(item, i) in agencies"
167
+                      :key="i"
168
+                      :value="item.id"
166 169
                     >
167
-                      {{ role.roleName }}
170
+                      {{ item.agencyName }}
168 171
                     </option>
169 172
                   </select>
170 173
                 </float-label>
171 174
               </div>
172
-              <div class="col-md-6">
173
-                <input
174
-                  class="mr-2 mt-3"
175
-                  name="changePass"
176
-                  type="checkbox"
177
-                  v-model="agent.user.loginPasswordChange"
178
-                />
179
-                <label for="changePass">Change Password on Next Login</label>
180
-              </div>
181 175
             </div>
182
-          </div>
183
-          <div class="row">
184
-            <div class="col">
185
-              <Alert :text="errorMessage" :type="errorOccurred" />
176
+
177
+            <div v-if="pullUserRole === 'Super Admin'">
178
+              <div class="row">
179
+                <div class="col">
180
+                  <div class="section-header">
181
+                    <h2>Access Control</h2>
182
+                  </div>
183
+                </div>
184
+              </div>
185
+
186
+              <div class="row">
187
+                <div class="col-md-6">
188
+                  <float-label label="User Role" style="width: 100%;">
189
+                    <select
190
+                      class="form-control uniSelect"
191
+                      id="howMarried"
192
+                      v-model="agent.user.role"
193
+                      v-bind:class="{
194
+                        'is-valid': agent.user.role,
195
+                        'is-invalid':
196
+                          !requiredField(agent.user.role) && userRoleLoad,
197
+                      }"
198
+                      v-on:keyup="userRoleLoad = true"
199
+                      v-on:blur="userRoleLoad = true"
200
+                    >
201
+                      <option
202
+                        v-for="role in getRoles"
203
+                        :key="role.id"
204
+                        :value="role.roleName"
205
+                      >
206
+                        {{ role.roleName }}
207
+                      </option>
208
+                    </select>
209
+                    <div class="invalid-feedback">
210
+                      User Role is Required!
211
+                    </div>
212
+                  </float-label>
213
+                </div>
214
+
215
+                <div class="col-md-6">
216
+                  <input
217
+                    class="mr-2 mt-3"
218
+                    name="changePass"
219
+                    type="checkbox"
220
+                    v-model="agent.user.loginPasswordChange"
221
+                  />
222
+                  <label for="changePass">Change Password on Next Login</label>
223
+                </div>
224
+              </div>
186 225
             </div>
187
-          </div>
188
-          <div class="row mt-5 mb-5">
189
-            <div class="col">
190
-              <button class="btn-solid-blue" @click="sendToApi()">SAVE</button>
226
+            <div class="row">
227
+              <div class="col">
228
+                <Alert :text="errorMessage" :type="errorOccurred" />
229
+              </div>
191 230
             </div>
192
-            <div class="col">
193
-              <button class="btn-solid-blue" @click="$router.go(-1)">
194
-                CLOSE
195
-              </button>
231
+            <div class="row mt-5 mb-5">
232
+              <div class="col">
233
+                <button class="btn-white-border" @click="sendToApi()">
234
+                  Save
235
+                </button>
236
+              </div>
237
+              <div class="col">
238
+                <button class="btn-white-border" @click="$router.go(-1)">
239
+                  Cancel
240
+                </button>
241
+              </div>
196 242
             </div>
197 243
           </div>
198 244
         </div>
@@ -208,97 +254,207 @@ import Log from '../../assets/Log'
208 254
 import Alert from '../shared/alert'
209 255
 
210 256
 export default {
211
-  props: {
212
-    agent: {},
213
-  },
257
+  name: 'UpdateAgentProfile',
214 258
   components: {
215 259
     Alert,
216 260
   },
217 261
   data() {
218 262
     return {
263
+      selectedItem: {},
264
+      agent: {},
219 265
       errorOccurred: '',
220 266
       errorMessage: '',
221
-      boolError: false,
267
+      boolMessage: false,
268
+      boolValidationError: false,
269
+      usernameLoad: false,
270
+      nameLoad: false,
271
+      surnameLoad: false,
272
+      emailAddressLoad: false,
273
+      cellNumberLoad: false,
274
+      telephoneNumberLoad: false,
275
+      spouseEmailLoad: false,
276
+      userRoleLoad: false,
277
+      inputAgencyLoad: false,
222 278
     }
223 279
   },
280
+  props: {},
224 281
   created() {
225 282
     this.retrieveUserRoles()
283
+    console.log('created')
284
+    this.getIndividual(Log.getUser().id).then(() => {
285
+      if (this.$route.params.agent) {
286
+        this.agent = this.$route.params.agent
287
+
288
+        //if (this.agent.address === null) {
289
+        //  this.agent.address = {}
290
+        //}
291
+
292
+        if (
293
+          this.agent.user.role === 'Agent' ||
294
+          this.agent.user.role === 'Agency' ||
295
+          this.agent.user.role === 'Management Agent'
296
+        ) {
297
+          this.getAgentById(this.agent.userId)
298
+          this.agent.agencyId = this.agent[0].agencyId
299
+        }
300
+      } else {
301
+        this.agent = this.indiv
302
+        this.agent.email = this.indiv.emailAddress
303
+        console.log(this.indiv)
304
+        this.agent.user = Log.getUser()
305
+      }
306
+    })
226 307
     this.getAgencies()
308
+    console.log('End created')
227 309
   },
228 310
   computed: {
229
-    ...mapGetters('role', ['getRoles']),
311
+    ...mapState('individual', ['indiv']),
230 312
     ...mapState('timeshare', ['agencies']),
313
+    ...mapState('authentication', ['isLoggedIn', 'user']),
314
+    ...mapGetters({
315
+      user: 'authentication/getUser',
316
+      person: 'authentication/getPerson',
317
+    }),
318
+    ...mapGetters('role', ['getRoles']),
319
+    isLoggedIn() {
320
+      return this.user && this.person
321
+    },
231 322
     pullUserRole() {
232 323
       return Log.getUser().role
233 324
     },
234 325
   },
235 326
   methods: {
327
+    ...mapActions('individual', ['getIndividual']),
236 328
     ...mapActions('role', ['retrieveUserRoles']),
329
+    ...mapActions('register', ['getAgentById', 'saveAgent']),
237 330
     ...mapActions('timeshare', ['getAgencies', 'updateAgent']),
238
-    ...mapActions('register', ['saveAgent']),
239
-    validPhoneNumber(number) {
240
-      const rx = /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im
241
-      return rx.test(String(number))
331
+    onSelectedItemItemChange(item) {
332
+      this.currentUser = item
242 333
     },
243 334
     sendToApi() {
244 335
       this.boolError = false
245 336
       this.agent.fullName = this.agent.name + ' ' + this.agent.surname
246
-      if (this.agent.telephone !== '') {
247
-        if (this.agent.telephone !== null) {
248
-          if (!this.validPhoneNumber(this.agent.telephone)) {
249
-            this.boolError = true
250
-            this.errorOccurred = 'ERROR'
251
-            this.errorMessage =
252
-              'The telephone number is not in the correct format.'
337
+      this.agent.emailAddress = this.agent.email
338
+      if (this.validatePage()) {
339
+        if (!this.boolValidationError) {
340
+          if (
341
+            this.agent.user.role === 'Agent' ||
342
+            this.agent.user.role === 'Agency' ||
343
+            this.agent.user.role === 'Managing Agent'
344
+          ) {
345
+            console.log('saveAgent')
346
+            console.log(this.agent)
347
+            this.saveAgent(this.agent)
348
+              .then(() => {
349
+                console.log('saveAgent 1')
350
+                console.log(this.agent)
351
+                this.boolMessage = true
352
+                if (Log.getUser().role === 'Super Admin') {
353
+                  console.log(this.agent)
354
+                  if (
355
+                    this.agent.id ===
356
+                    JSON.parse(localStorage.getItem('person')).id
357
+                  ) {
358
+                    var newPerson = {
359
+                      id: JSON.parse(localStorage.getItem('person')).id,
360
+                      email: this.agent.email,
361
+                      fullname: this.agent.name + ' ' + this.agent.surname,
362
+                      name: this.agent.name,
363
+                      surname: this.agent.surname,
364
+                    }
365
+                    localStorage.setItem('person', JSON.stringify(newPerson))
366
+                    this.$router.go()
367
+                  }
368
+                  if (Log.getUser().role === 'Super Admin') {
369
+                    this.$router.push('/status/userManagementPage')
370
+                  } else {
371
+                    this.$router.push('/')
372
+                  }
373
+                } else {
374
+                  var newPerson = {
375
+                    id: JSON.parse(localStorage.getItem('person')).id,
376
+                    email: this.agent.email,
377
+                    fullname: this.agent.name + ' ' + this.agent.surname,
378
+                    name: this.agent.name,
379
+                    surname: this.agent.surname,
380
+                  }
381
+                  localStorage.setItem('person', JSON.stringify(newPerson))
382
+                  this.$router.go()
383
+                }
384
+              })
385
+              .catch((err) => {
386
+                console.log(err)
387
+                this.errorOccurred = 'ERRORHTML'
388
+
389
+                this.errorOccurred = 'ERROR'
390
+                this.errorMessage = 'Server Error: CONNECTION_REFUSED'
391
+                console.log(err.status)
392
+                if (err.status) {
393
+                  if (err.data.message) {
394
+                    this.errorMessage = err.data.message
395
+                  } else {
396
+                    this.errorMessage = err
397
+                  }
398
+                }
399
+              })
253 400
           }
254 401
         }
402
+      }
403
+    },
404
+    requiredField: function (tfield) {
405
+      if (tfield) {
406
+        return true
255 407
       } else {
256
-        this.agent.telephone = null
408
+        return false
257 409
       }
258
-      if (this.agent.cellNumber !== '') {
259
-        if (this.agent.cellNumber !== null) {
260
-          if (!this.validPhoneNumber(this.agent.cellNumber)) {
261
-            this.boolError = true
262
-            this.errorOccurred = 'ERROR'
263
-            this.errorMessage =
264
-              'The cellphone number is not in the correct format.'
265
-          }
266
-        }
410
+    },
411
+    validEmail: function (email) {
412
+      var re = /(.+)@(.+){2,}\.(.+){2,}/
413
+      if (email) {
414
+        return re.test(email.toLowerCase())
267 415
       } else {
268
-        this.agent.cellNumber = null
416
+        return re.test(email)
269 417
       }
418
+    },
419
+    validPhoneNumber(number) {
420
+      if (number) {
421
+        const rx = /^\(?\d{3}\)?[-\s]?\d{3}[-\s]?\d{4}$/
422
+        // const rx = /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im
423
+        return rx.test(String(number))
424
+      } else {
425
+        return true
426
+      }
427
+    },
428
+    validatePage: function () {
429
+      console.log('validatePage')
430
+      if (
431
+        this.agent.name &&
432
+        this.agent.surname &&
433
+        this.agent.emailAddress &&
434
+        this.agent.cellNumber &&
435
+        this.agent.user.role &&
436
+        this.validEmail(this.agent.emailAddress) &&
437
+        this.validPhoneNumber(this.agent.cellNumber) &&
438
+        this.validPhoneNumber(this.agent.telephone)
439
+      ) {
440
+        console.log('passed')
441
+        this.errorOccurred = ''
442
+        this.errorMessage = ''
443
+        this.boolValidationError = false
270 444
 
271
-      if (!this.boolError) {
272
-        if (
273
-          this.agent.user.role === 'Agent' ||
274
-          this.agent.user.role === 'Agency' ||
275
-          this.agent.user.role === 'Managing Agent'
276
-        ) {
277
-          this.updateAgent(this.agent).then(() => {
278
-            var newPerson = {
279
-              id: JSON.parse(localStorage.getItem('person')).id,
280
-              email: this.agent.email,
281
-              fullname: this.agent.name + ' ' + this.agent.surname,
282
-              name: this.agent.name,
283
-              surname: this.agent.surnmame,
284
-            }
285
-            localStorage.setItem('person', JSON.stringify(newPerson))
286
-            console.log(newPerson)
287
-            this.$router.push('/')
288
-          })
289
-        } else {
290
-          this.saveAgent(this.agent)
291
-            .then(() => {
292
-              if (Log.getUser().role === 'Super Admin') {
293
-                this.$router.push('/status/userManagementPage')
294
-              } else {
295
-                this.$router.push('/')
296
-              }
297
-            })
298
-            .catch((ex) => {
299
-              console.log(ex)
300
-            })
301
-        }
445
+        return true
446
+      } else {
447
+        console.log('failed')
448
+        this.nameLoad = true
449
+        this.surnameLoad = true
450
+        this.emailAddressLoadLoad = true
451
+        this.cellNumberLoad = true
452
+        this.telephoneLoad = true
453
+        this.userRoleLoad = true
454
+        this.boolValidationError = true
455
+        this.errorOccurred = 'ERROR'
456
+        this.errorMessage = 'Please check form and correct all input fields!'
457
+        return false
302 458
       }
303 459
     },
304 460
   },

+ 30
- 17
src/components/user/updateProfileInfo.vue Ver fichero

@@ -31,7 +31,7 @@
31 31
                 type="text"
32 32
                 name="username"
33 33
                 class="form-control uniInput"
34
-                id="name"
34
+                id="username"
35 35
                 placeholder="Name"
36 36
                 data-rule="minlen:4"
37 37
                 data-msg="Please enter your name"
@@ -194,14 +194,15 @@
194 194
                 v-bind:class="{
195 195
                   'is-valid': individual.cellNumber,
196 196
                   'is-invalid':
197
-                    !requiredField(validPhoneNumber(individual.cellNumber)) &&
197
+                    validPhoneNumber(individual.cellNumber) &&
198
+                    !requiredField(individual.cellNumber) &&
198 199
                     cellNumberLoad,
199 200
                 }"
200 201
                 v-on:keyup="cellNumberLoad = true"
201 202
                 v-on:blur="cellNumberLoad = true"
202 203
               />
203 204
               <div class="invalid-feedback">
204
-                Cell Number is Required!
205
+                Valid Cell Number is Required!
205 206
               </div>
206 207
             </float-label>
207 208
           </div>
@@ -210,10 +211,10 @@
210 211
               <input
211 212
                 type="text"
212 213
                 class="form-control uniInput"
213
-                name="landline"
214
-                id="landline"
214
+                name="telephone"
215
+                id="telephone"
215 216
                 placeholder="Telephone Number"
216
-                data-msg="Please enter your landline number"
217
+                data-msg="Please enter your Telephone number"
217 218
                 v-model="individual.telephone"
218 219
                 v-bind:class="{
219 220
                   'is-valid':
@@ -223,8 +224,6 @@
223 224
                     individual.telephone &&
224 225
                     !validPhoneNumber(individual.telephone),
225 226
                 }"
226
-                v-on:keyup="landlineNumberLoad = true"
227
-                v-on:blur="landlineNumberLoad = true"
228 227
               />
229 228
               <div class="invalid-feedback">
230 229
                 Valid telephone number is required!!
@@ -301,7 +300,7 @@
301 300
                 <input
302 301
                   type="text"
303 302
                   class="form-control uniInput"
304
-                  placeholder="SPOUSE CELL NUMBER"
303
+                  placeholder="Spouse Cell Number"
305 304
                   data-rule="minlen:4"
306 305
                   data-msg="Please enter your spouse's cellphone number"
307 306
                   v-model="individual.spouseCellnumber"
@@ -463,7 +462,11 @@
463 462
                   v-model="individual.agencyId"
464 463
                   v-bind:class="{
465 464
                     'is-valid': individual.agencyId,
465
+                    'is-invalid':
466
+                      !requiredField(individual.agencyId) && inputAgencyLoad,
466 467
                   }"
468
+                  v-on:keyup="inputAgencyLoad = true"
469
+                  v-on:blur="inputAgencyLoad = true"
467 470
                 >
468 471
                   <option value="">Private User</option>
469 472
                   <option
@@ -541,6 +544,7 @@ export default {
541 544
       landlineNumberLoad: false,
542 545
       spouseEmailLoad: false,
543 546
       userRoleLoad: false,
547
+      inputAgencyLoad: false,
544 548
     }
545 549
   },
546 550
   props: {},
@@ -617,9 +621,9 @@ export default {
617 621
     },
618 622
     isAgent() {
619 623
       if (
620
-        this.individual.user.role.toUpperCase() === 'AGENCY' ||
621
-        this.individual.user.role.toUpperCase() === 'AGENT' ||
622
-        this.individual.user.role.toUpperCase() === 'MANAGING AGENT'
624
+        this.individual.user.role === 'Agency' ||
625
+        this.individual.user.role === 'Agent' ||
626
+        this.individual.user.role === 'Managing Agent'
623 627
       ) {
624 628
         return true
625 629
       } else {
@@ -646,12 +650,15 @@ export default {
646 650
             this.individual.user.role === 'Agent' ||
647 651
             this.individual.user.role === 'Managing Agent'
648 652
           ) {
653
+            console.log('saveAgent')
654
+            console.log(this.individual)
649 655
             this.saveAgent(this.individual)
650 656
               .then(() => {
657
+                console.log('saveAgent 1')
658
+                console.log(this.individual)
651 659
                 this.boolMessage = true
652 660
                 if (Log.getUser().role === 'Super Admin') {
653
-                  // console.log(this.individual);
654
-                  // console.log(JSON.parse(localStorage.getItem("person")));
661
+                  console.log(this.individual)
655 662
                   if (
656 663
                     this.individual.id ===
657 664
                     JSON.parse(localStorage.getItem('person')).id
@@ -681,8 +688,8 @@ export default {
681 688
                   this.$router.go()
682 689
                 }
683 690
               })
684
-              .catch((ex) => {
685
-                console.log(ex)
691
+              .catch((err) => {
692
+                console.log(err)
686 693
                 this.errorOccurred = 'ERRORHTML'
687 694
 
688 695
                 this.errorOccurred = 'ERROR'
@@ -692,7 +699,7 @@ export default {
692 699
                   if (err.data.message) {
693 700
                     this.errorMessage = err.data.message
694 701
                   } else {
695
-                    this.errorMessage = ex
702
+                    this.errorMessage = err
696 703
                   }
697 704
                 }
698 705
               })
@@ -700,10 +707,13 @@ export default {
700 707
             this.updateIndividual(this.individual).then(() => {
701 708
               this.boolMessage = true
702 709
               if (Log.getUser().role === 'Super Admin') {
710
+                console.log('updateIndividual')
711
+                console.log(this.individual)
703 712
                 if (
704 713
                   this.individual.id ===
705 714
                   JSON.parse(localStorage.getItem('person')).id
706 715
                 ) {
716
+                  console.log('here 1')
707 717
                   var newPerson = {
708 718
                     id: JSON.parse(localStorage.getItem('person')).id,
709 719
                     email: this.individual.email,
@@ -717,6 +727,7 @@ export default {
717 727
                 }
718 728
                 //this.$router.push('/status/userManagementPage')
719 729
               } else {
730
+                console.log('here 2')
720 731
                 var newPerson = {
721 732
                   id: JSON.parse(localStorage.getItem('person')).id,
722 733
                   email: this.individual.email,
@@ -773,6 +784,7 @@ export default {
773 784
         this.errorOccurred = ''
774 785
         this.errorMessage = ''
775 786
         this.boolValidationError = false
787
+
776 788
         return true
777 789
       } else {
778 790
         console.log('failed')
@@ -780,6 +792,7 @@ export default {
780 792
         this.surnameLoad = true
781 793
         this.emailAddressLoadLoad = true
782 794
         this.cellNumberLoad = true
795
+        this.telephoneLoad = true
783 796
         this.userRoleLoad = true
784 797
         this.boolValidationError = true
785 798
         this.errorOccurred = 'ERROR'

+ 9
- 1
src/store/modules/user/register.js Ver fichero

@@ -85,6 +85,7 @@ export default {
85 85
                 surname: '',
86 86
                 email: '',
87 87
                 cellNumber: '',
88
+                telephone: '',
88 89
                 username: '',
89 90
                 password: '',
90 91
                 acceptedTerms: false,
@@ -211,17 +212,24 @@ export default {
211 212
             await axios
212 213
                 .post('/api/agent/AgentFromUser', item)
213 214
                 .then((res) => {
215
+                    console.log('saveAgent')
216
+                    console.log(res)
214 217
                     commit('addAgent', res.data)
215 218
                     return Promise.resolve(res)
216 219
                 })
217 220
                 .catch((ex) => {
221
+                    console.log('saveAgent API failed')
222
+                    console.log(ex.response)
218 223
                     return Promise.reject(ex.response)
219 224
                 })
220 225
         },
221 226
         async updateIndividual({ commit }, userParam) {
222 227
             await axios
223 228
                 .put('/api/user/', userParam)
224
-                .then((result) => console.log(result))
229
+                .then((result) => {
230
+                    console.log('register updateIndividuals')
231
+                    console.log(result)
232
+                })
225 233
                 .catch(console.error)
226 234
         },
227 235
         updateAgency({ commit }, item) {

Loading…
Cancelar
Guardar