|
@@ -10,20 +10,20 @@
|
10
|
10
|
</div>
|
11
|
11
|
<div class="row mb-4">
|
12
|
12
|
<div class="col-md-6">
|
13
|
|
- <float-label fixed label="username">
|
|
13
|
+ <float-label fixed label="Username">
|
14
|
14
|
<input
|
15
|
15
|
type="text"
|
16
|
16
|
name="username"
|
17
|
17
|
class="form-control uniinput"
|
18
|
18
|
id="username"
|
19
|
|
- placeholder="name"
|
|
19
|
+ placeholder="Username"
|
20
|
20
|
data-rule="minlen:4"
|
21
|
|
- data-msg="please enter your name"
|
|
21
|
+ data-msg="please enter your username"
|
22
|
22
|
v-model="agent.user.username"
|
23
|
23
|
v-bind:class="{
|
24
|
24
|
'is-valid': agent.user.username,
|
25
|
25
|
'is-invalid':
|
26
|
|
- !requiredfield(agent.user.username) && usernameload,
|
|
26
|
+ !requiredField(agent.user.username) && usernameLoad,
|
27
|
27
|
}"
|
28
|
28
|
v-on:keyup="usernameLoad = true"
|
29
|
29
|
v-on:blur="usernameLoad = true"
|
|
@@ -32,7 +32,7 @@
|
32
|
32
|
</float-label>
|
33
|
33
|
</div>
|
34
|
34
|
<div class="form-group col-md-6">
|
35
|
|
- <float-label>
|
|
35
|
+ <float-label fixed label="Name">
|
36
|
36
|
<input
|
37
|
37
|
type="text"
|
38
|
38
|
name="name"
|
|
@@ -55,7 +55,7 @@
|
55
|
55
|
</div>
|
56
|
56
|
<div class="row mt-4">
|
57
|
57
|
<div class="form-group col-md-6">
|
58
|
|
- <float-label>
|
|
58
|
+ <float-label fixed label="Surname">
|
59
|
59
|
<input
|
60
|
60
|
type="text"
|
61
|
61
|
class="form-control uniInput"
|
|
@@ -75,7 +75,7 @@
|
75
|
75
|
</float-label>
|
76
|
76
|
</div>
|
77
|
77
|
<div class="form-group col-md-6">
|
78
|
|
- <float-label>
|
|
78
|
+ <float-label fixed label="Email">
|
79
|
79
|
<input
|
80
|
80
|
type="text"
|
81
|
81
|
class="form-control uniInput"
|
|
@@ -85,7 +85,7 @@
|
85
|
85
|
data-msg="Please enter your email address"
|
86
|
86
|
v-model="agent.email"
|
87
|
87
|
v-bind:class="{
|
88
|
|
- 'is-valid': agent.email,
|
|
88
|
+ 'is-valid': agent.email && validEmail(agent.email),
|
89
|
89
|
'is-invalid': !validEmail(agent.email) && emailAddressLoad,
|
90
|
90
|
}"
|
91
|
91
|
v-on:keyup="emailAddressLoad = true"
|
|
@@ -99,7 +99,7 @@
|
99
|
99
|
</div>
|
100
|
100
|
<div class="row mt-4">
|
101
|
101
|
<div class="form-group col-md-6">
|
102
|
|
- <float-label>
|
|
102
|
+ <float-label fixed label="Cell Number">
|
103
|
103
|
<input
|
104
|
104
|
type="text"
|
105
|
105
|
name="cell"
|
|
@@ -110,11 +110,13 @@
|
110
|
110
|
data-msg="Please enter your cell number"
|
111
|
111
|
v-model="agent.cellNumber"
|
112
|
112
|
v-bind:class="{
|
113
|
|
- 'is-valid': agent.cellNumber,
|
|
113
|
+ 'is-valid':
|
|
114
|
+ agent.cellNumber && validPhoneNumber(agent.cellNumber),
|
114
|
115
|
'is-invalid':
|
115
|
|
- validPhoneNumber(agent.cellNumber) &&
|
116
|
|
- !requiredField(agent.cellNumber) &&
|
117
|
|
- cellNumberLoad,
|
|
116
|
+ !requiredField(agent.cellNumber) ||
|
|
117
|
+ (agent.cellNumber &&
|
|
118
|
+ !validPhoneNumber(agent.cellNumber) &&
|
|
119
|
+ cellNumberLoad),
|
118
|
120
|
}"
|
119
|
121
|
v-on:keyup="cellNumberLoad = true"
|
120
|
122
|
v-on:blur="cellNumberLoad = true"
|
|
@@ -125,7 +127,7 @@
|
125
|
127
|
</float-label>
|
126
|
128
|
</div>
|
127
|
129
|
<div class="form-group col-md-6">
|
128
|
|
- <float-label>
|
|
130
|
+ <float-label fixed label="Telephone Number">
|
129
|
131
|
<input
|
130
|
132
|
type="text"
|
131
|
133
|
class="form-control uniInput"
|
|
@@ -224,14 +226,24 @@
|
224
|
226
|
</div>
|
225
|
227
|
</div>
|
226
|
228
|
<div class="row">
|
227
|
|
- <div class="col">
|
228
|
|
- <Alert :text="errorMessage" :type="errorOccurred" />
|
|
229
|
+ <div v-if="boolMessage" class="row">
|
|
230
|
+ <div class="col">
|
|
231
|
+ <alert
|
|
232
|
+ :text="'Your Information has been updated!'"
|
|
233
|
+ :type="'SUCCESS'"
|
|
234
|
+ />
|
|
235
|
+ </div>
|
|
236
|
+ </div>
|
|
237
|
+ <div v-if="boolValidationError" class="row">
|
|
238
|
+ <div class="col">
|
|
239
|
+ <alert :text="errorMessage" :type="errorOccurred" />
|
|
240
|
+ </div>
|
229
|
241
|
</div>
|
230
|
242
|
</div>
|
231
|
243
|
<div class="row mt-5 mb-5">
|
232
|
244
|
<div class="col">
|
233
|
245
|
<button class="btn-white-border" @click="sendToApi()">
|
234
|
|
- Save
|
|
246
|
+ Update
|
235
|
247
|
</button>
|
236
|
248
|
</div>
|
237
|
249
|
<div class="col">
|
|
@@ -280,14 +292,13 @@ export default {
|
280
|
292
|
props: {},
|
281
|
293
|
created() {
|
282
|
294
|
this.retrieveUserRoles()
|
283
|
|
- console.log('created')
|
284
|
295
|
this.getIndividual(Log.getUser().id).then(() => {
|
285
|
296
|
if (this.$route.params.agent) {
|
286
|
297
|
this.agent = this.$route.params.agent
|
287
|
298
|
|
288
|
|
- //if (this.agent.address === null) {
|
289
|
|
- // this.agent.address = {}
|
290
|
|
- //}
|
|
299
|
+ if (this.agent.address === null) {
|
|
300
|
+ this.agent.address = {}
|
|
301
|
+ }
|
291
|
302
|
|
292
|
303
|
if (
|
293
|
304
|
this.agent.user.role === 'Agent' ||
|
|
@@ -295,7 +306,7 @@ export default {
|
295
|
306
|
this.agent.user.role === 'Management Agent'
|
296
|
307
|
) {
|
297
|
308
|
this.getAgentById(this.agent.userId)
|
298
|
|
- this.agent.agencyId = this.agent[0].agencyId
|
|
309
|
+ this.agent.agencyId = this.agent.agencyId
|
299
|
310
|
}
|
300
|
311
|
} else {
|
301
|
312
|
this.agent = this.indiv
|
|
@@ -305,12 +316,11 @@ export default {
|
305
|
316
|
}
|
306
|
317
|
})
|
307
|
318
|
this.getAgencies()
|
308
|
|
- console.log('End created')
|
|
319
|
+ this.selectedItem = this.currentUser
|
309
|
320
|
},
|
310
|
321
|
computed: {
|
311
|
322
|
...mapState('individual', ['indiv']),
|
312
|
|
- ...mapState('timeshare', ['agencies']),
|
313
|
|
- ...mapState('authentication', ['isLoggedIn', 'user']),
|
|
323
|
+ ...mapState('register', ['agencies']),
|
314
|
324
|
...mapGetters({
|
315
|
325
|
user: 'authentication/getUser',
|
316
|
326
|
person: 'authentication/getPerson',
|
|
@@ -324,10 +334,14 @@ export default {
|
324
|
334
|
},
|
325
|
335
|
},
|
326
|
336
|
methods: {
|
327
|
|
- ...mapActions('individual', ['getIndividual']),
|
|
337
|
+ ...mapActions('individual', ['getIndividual', 'updateIndividual']),
|
328
|
338
|
...mapActions('role', ['retrieveUserRoles']),
|
329
|
|
- ...mapActions('register', ['getAgentById', 'saveAgent']),
|
330
|
|
- ...mapActions('timeshare', ['getAgencies', 'updateAgent']),
|
|
339
|
+ ...mapActions('register', [
|
|
340
|
+ 'getAgentById',
|
|
341
|
+ 'getAgencies',
|
|
342
|
+ 'saveAgent',
|
|
343
|
+ 'updateAgent',
|
|
344
|
+ ]),
|
331
|
345
|
onSelectedItemItemChange(item) {
|
332
|
346
|
this.currentUser = item
|
333
|
347
|
},
|
|
@@ -365,11 +379,7 @@ export default {
|
365
|
379
|
localStorage.setItem('person', JSON.stringify(newPerson))
|
366
|
380
|
this.$router.go()
|
367
|
381
|
}
|
368
|
|
- if (Log.getUser().role === 'Super Admin') {
|
369
|
|
- this.$router.push('/status/userManagementPage')
|
370
|
|
- } else {
|
371
|
|
- this.$router.push('/')
|
372
|
|
- }
|
|
382
|
+ //this.$router.push('/status/agentuserManagementPage')
|
373
|
383
|
} else {
|
374
|
384
|
var newPerson = {
|
375
|
385
|
id: JSON.parse(localStorage.getItem('person')).id,
|
|
@@ -397,6 +407,41 @@ export default {
|
397
|
407
|
}
|
398
|
408
|
}
|
399
|
409
|
})
|
|
410
|
+ } else {
|
|
411
|
+ this.updateAgent(this.agent).then(() => {
|
|
412
|
+ this.boolMessage = true
|
|
413
|
+ if (Log.getUser().role === 'Super Admin') {
|
|
414
|
+ console.log('updateIndividual')
|
|
415
|
+ console.log(this.agent)
|
|
416
|
+ if (
|
|
417
|
+ this.agent.id ===
|
|
418
|
+ JSON.parse(localStorage.getItem('person')).id
|
|
419
|
+ ) {
|
|
420
|
+ console.log('here 1')
|
|
421
|
+ var newPerson = {
|
|
422
|
+ id: JSON.parse(localStorage.getItem('person')).id,
|
|
423
|
+ email: this.agent.email,
|
|
424
|
+ fullname: this.agent.name + ' ' + this.agent.surname,
|
|
425
|
+ name: this.agent.name,
|
|
426
|
+ surname: this.agent.surname,
|
|
427
|
+ }
|
|
428
|
+ localStorage.setItem('person', JSON.stringify(newPerson))
|
|
429
|
+ //this.$router.go()
|
|
430
|
+ }
|
|
431
|
+ //this.$router.push('/status/userManagementPage')
|
|
432
|
+ } else {
|
|
433
|
+ console.log('here 2')
|
|
434
|
+ var newPerson = {
|
|
435
|
+ id: JSON.parse(localStorage.getItem('person')).id,
|
|
436
|
+ email: this.agent.email,
|
|
437
|
+ fullname: this.agent.name + ' ' + this.agent.surname,
|
|
438
|
+ name: this.agent.name,
|
|
439
|
+ surname: this.agent.surname,
|
|
440
|
+ }
|
|
441
|
+ localStorage.setItem('person', JSON.stringify(newPerson))
|
|
442
|
+ //this.$router.go()
|
|
443
|
+ }
|
|
444
|
+ })
|
400
|
445
|
}
|
401
|
446
|
}
|
402
|
447
|
}
|