Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

updateAgentProfile.vue 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <main id="main">
  3. <section id="contact2">
  4. <div class="container">
  5. <div class="form">
  6. <div class="row">
  7. <div class="section-header">
  8. <h2>Update Agent Info</h2>
  9. </div>
  10. </div>
  11. <div class="row">
  12. <div class="col">
  13. <float-label>
  14. <input
  15. type="text"
  16. name="name"
  17. class="form-control uniInput"
  18. id="name"
  19. placeholder="USERNAME"
  20. data-rule="minlen:4"
  21. data-msg="Please enter your name"
  22. v-model="agent.user.username"
  23. />
  24. </float-label>
  25. </div>
  26. <div class="col">
  27. <float-label>
  28. <input
  29. type="text"
  30. name="name"
  31. class="form-control uniInput"
  32. id="name"
  33. placeholder="NAME"
  34. data-rule="minlen:4"
  35. data-msg="Please enter your name"
  36. v-model="agent.name"
  37. />
  38. </float-label>
  39. </div>
  40. </div>
  41. <div class="row mt-4">
  42. <div class="col-md-6">
  43. <float-label>
  44. <input
  45. type="text"
  46. class="form-control uniInput"
  47. name="surname"
  48. id="surname"
  49. placeholder="SURNAME"
  50. data-msg="Please enter your surname"
  51. v-model="agent.surname"
  52. />
  53. </float-label>
  54. </div>
  55. <div class="col">
  56. <float-label>
  57. <input
  58. type="text"
  59. class="form-control uniInput"
  60. name="email"
  61. id="email"
  62. placeholder="EMAIL ADDRESS"
  63. data-msg="Please enter your email address"
  64. v-model="agent.email"
  65. />
  66. </float-label>
  67. </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. </div>
  96. </div> -->
  97. <div class="row mt-4">
  98. <div class="col">
  99. <float-label>
  100. <input
  101. type="text"
  102. name="cell"
  103. class="form-control uniInput"
  104. id="cell"
  105. placeholder="CELL NUMBER"
  106. data-rule="minlen:4"
  107. data-msg="Please enter your cell number"
  108. v-model="agent.cellNumber"
  109. />
  110. </float-label>
  111. </div>
  112. <div class="col">
  113. <float-label>
  114. <input
  115. type="text"
  116. class="form-control uniInput"
  117. name="landline"
  118. id="landline"
  119. placeholder="TELEPHONE NUMBER"
  120. data-msg="Please enter your Telephone number"
  121. v-model="agent.telephone"
  122. />
  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>
  151. </div>
  152. </div>
  153. </div>
  154. <div class="row">
  155. <div class="col-md-6">
  156. <float-label label="User Role" style="width: 100%;">
  157. <select
  158. class="form-control uniSelect"
  159. id="howMarried"
  160. v-model="agent.user.role"
  161. >
  162. <option
  163. v-for="role in getRoles"
  164. :key="role.id"
  165. :value="role.roleName"
  166. >
  167. {{ role.roleName }}
  168. </option>
  169. </select>
  170. </float-label>
  171. </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. </div>
  182. </div>
  183. <div class="row">
  184. <div class="col">
  185. <Alert :text="errorMessage" :type="errorOccurred" />
  186. </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>
  191. </div>
  192. <div class="col">
  193. <button class="btn-solid-blue" @click="$router.go(-1)">
  194. CLOSE
  195. </button>
  196. </div>
  197. </div>
  198. </div>
  199. </div>
  200. </section>
  201. </main>
  202. </template>
  203. <script>
  204. /* eslint-disable */
  205. import { mapState, mapActions, mapGetters } from 'vuex'
  206. import Log from '../../assets/Log'
  207. import Alert from '../shared/alert'
  208. export default {
  209. props: {
  210. agent: {},
  211. },
  212. components: {
  213. Alert,
  214. },
  215. data() {
  216. return {
  217. errorOccurred: '',
  218. errorMessage: '',
  219. boolError: false,
  220. }
  221. },
  222. created() {
  223. this.retrieveUserRoles()
  224. this.getAgencies()
  225. },
  226. computed: {
  227. ...mapGetters('role', ['getRoles']),
  228. ...mapState('timeshare', ['agencies']),
  229. pullUserRole() {
  230. return Log.getUser().role
  231. },
  232. },
  233. methods: {
  234. ...mapActions('role', ['retrieveUserRoles']),
  235. ...mapActions('timeshare', ['getAgencies', 'updateAgent']),
  236. ...mapActions('register', ['saveAgent']),
  237. validPhoneNumber(number) {
  238. const rx = /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im
  239. return rx.test(String(number))
  240. },
  241. sendToApi() {
  242. this.boolError = false
  243. this.agent.fullName = this.agent.name + ' ' + this.agent.surname
  244. if (this.agent.telephone !== '') {
  245. if (this.agent.telephone !== null) {
  246. if (!this.validPhoneNumber(this.agent.telephone)) {
  247. this.boolError = true
  248. this.errorOccurred = 'ERROR'
  249. this.errorMessage =
  250. 'The telephone number is not in the correct format.'
  251. }
  252. }
  253. } else {
  254. this.agent.telephone = null
  255. }
  256. if (this.agent.cellNumber !== '') {
  257. if (this.agent.cellNumber !== null) {
  258. if (!this.validPhoneNumber(this.agent.cellNumber)) {
  259. this.boolError = true
  260. this.errorOccurred = 'ERROR'
  261. this.errorMessage =
  262. 'The cellphone number is not in the correct format.'
  263. }
  264. }
  265. } else {
  266. this.agent.cellNumber = null
  267. }
  268. if (!this.boolError) {
  269. if (
  270. this.agent.user.role === 'Agent' ||
  271. this.agent.user.role === 'Agency' ||
  272. this.agent.user.role === 'Managing Agent'
  273. ) {
  274. this.updateAgent(this.agent).then(() => {
  275. var newPerson = {
  276. id: JSON.parse(localStorage.getItem('person')).id,
  277. email: this.agent.email,
  278. fullname: this.agent.name + ' ' + this.agent.surname,
  279. name: this.agent.name,
  280. surname: this.agent.surnmame,
  281. }
  282. localStorage.setItem('person', JSON.stringify(newPerson))
  283. console.log(newPerson)
  284. this.$router.push('/')
  285. })
  286. } else {
  287. this.saveAgent(this.agent)
  288. .then(() => {
  289. if (Log.getUser().role === 'Super Admin') {
  290. this.$router.push('/status/userManagementPage')
  291. } else {
  292. this.$router.push('/')
  293. }
  294. })
  295. .catch((ex) => {
  296. console.log(ex)
  297. })
  298. }
  299. }
  300. },
  301. },
  302. }
  303. </script>
  304. <style lang="scss" scoped></style>