Guest User

Untitled

a guest
Mar 6th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.27 KB | None | 0 0
  1. <template>
  2. <div class="signup-page edit-expert">
  3. <div class="block-form" v-loading="initIsLoading">
  4. <el-form :model="joinForm" :rules="rules" ref="joinForm" id="joinForm">
  5. <div class="d-flex change-img">
  6. <el-col :xl="3" :lg="5" :md="5" :sm="24" :xs="24">
  7. <div class="user-img" :style="{ 'background-image' : `url( '../../../static/img/default-image.png')` , 'background-size' : 'cover' }" v-if="!item.image"></div>
  8. <div class="user-img" :style="{ 'background-image' : `url( ${ item.image } )` }" v-if="item.image && !changeImg"></div>
  9. <div class="user-img" :style="{ 'background-image' : `url(${ item.image } )` }" v-if="item.image && changeImg"></div>
  10. </el-col>
  11. <el-col :xl="21" :lg="19" :md="19" :sm="24" :xs="24">
  12. <el-button type="button" class="add-img" :loading="addImage_isLoading">
  13. Add Image
  14. <input type="file" @change="onFileChange($event)">
  15. </el-button>
  16. </el-col>
  17. </div>
  18. <el-row>
  19. <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  20. <h2>YOUR DETAILS</h2>
  21. </el-col>
  22. </el-row>
  23. <el-row>
  24. <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
  25. <el-form-item label="Title" prop="title">
  26. <el-select v-model="joinForm.title" placeholder="Select">
  27. <el-option v-for="title in titles" :label="title.value" :value="title.id" :key="title.id"></el-option>
  28. </el-select>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
  32. <el-form-item required label="First name" prop="first_name">
  33. <el-input v-model="joinForm.first_name" placeholder="Your first name" />
  34. </el-form-item>
  35. </el-col>
  36. <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
  37. <el-form-item required label="Surname" prop="last_name">
  38. <el-input v-model="joinForm.last_name" placeholder="Your surname" />
  39. </el-form-item>
  40. </el-col>
  41. <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
  42. <el-form-item required label="Email address" prop="email">
  43. <el-input type="email" v-model="joinForm.email" placeholder="Your email address" disabled/>
  44. </el-form-item>
  45. </el-col>
  46. </el-row>
  47. <el-row>
  48. <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
  49. <el-form-item required label="Timezone" prop="timezone">
  50. <el-select v-model="joinForm.timezone" filterable placeholder="Select timezone">
  51. <el-option v-for="timezone in timezones[0]" :value="timezone.timezone" :label="`${timezone.timezone} ${timezone.pretty_offset}`" :key="timezone.timezone"></el-option>
  52. </el-select>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
  56. <el-form-item required label="Country" prop="company_country_id">
  57. <el-select v-model="joinForm.company_country_id" filterable placeholder="Select country">
  58. <el-option v-for="companyCountry in companyCountries[0]" :value="companyCountry.id" :label="companyCountry.name" :key="companyCountry.id"></el-option>
  59. </el-select>
  60. </el-form-item>
  61. </el-col>
  62. <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24" class="edit-profile-industry">
  63. <el-form-item required label="Industry sector" prop="group_ids">
  64. <el-select v-model="joinForm.group_ids" multiple placeholder="Select industry sectors" :disabled="true">
  65. <el-option v-for="group in groups[0]" :value="group.id" :label="group.name" :key="group.id" />
  66. </el-select>
  67. <label class="el-form-item__label text-left">
  68. Info: Please get in touch with our support to update these.
  69. </label>
  70. </el-form-item>
  71. </el-col>
  72. <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24" class="edit-profile-tags">
  73. <el-form-item required label="Areas of expertise" prop="tag_ids">
  74. <el-select v-model="joinForm.tag_ids" multiple placeholder="Select area of expertises" :disabled="true">
  75. <el-option v-for="tag in tags[0]" :value="tag.id" :label="tag.name" :key="tag.id" />
  76. </el-select>
  77. <label class="el-form-item__label text-left">
  78. Info: Please get in touch with our support to update these.
  79. </label>
  80. </el-form-item>
  81. </el-col>
  82. </el-row>
  83. <el-row>
  84. <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  85. <h2>COMPANY DETAILS</h2>
  86. </el-col>
  87. <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
  88. <el-form-item label="Name" prop="company_name">
  89. <el-input v-model="joinForm.company_name" placeholder="Company name" />
  90. </el-form-item>
  91. </el-col>
  92. <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
  93. <el-form-item label="Position" prop="company_position">
  94. <el-input v-model="joinForm.company_position" placeholder="Company position" />
  95. </el-form-item>
  96. </el-col>
  97. <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
  98. <el-form-item label="Street number or name" prop="company_street">
  99. <el-input v-model="joinForm.company_street" placeholder="Company street number or name" />
  100. </el-form-item>
  101. </el-col>
  102. <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
  103. <el-form-item label="Town" prop="company_town">
  104. <el-input v-model="joinForm.company_town" placeholder="Company town" />
  105. </el-form-item>
  106. </el-col>
  107. <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
  108. <el-form-item label="Region/State" prop="company_region">
  109. <el-input v-model="joinForm.company_region" placeholder="Company region/state" />
  110. </el-form-item>
  111. </el-col>
  112. <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
  113. <el-form-item label="Postcode" prop="company_postcode">
  114. <el-input v-model="joinForm.company_postcode" placeholder="Company postcode" />
  115. </el-form-item>
  116. </el-col>
  117. <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
  118. <el-form-item label="Vat Number" prop="company_vat_no">
  119. <el-input v-model="joinForm.company_vat_no" placeholder="Company VAT Number" />
  120. </el-form-item>
  121. </el-col>
  122. </el-row>
  123. <el-row>
  124. <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  125. <h2>OTHER DETAILS</h2>
  126. </el-col>
  127. <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
  128. <el-form-item required label="Hourly rate (in GBP)" prop="hour_rate">
  129. <div class="el-input">
  130. <vue-numeric currency="£" separator="," :precision="2" v-model="joinForm.hour_rate" class="el-input__inner" :disabled="true"></vue-numeric>
  131. </div>
  132. </el-form-item>
  133. </el-col>
  134. <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
  135. <el-form-item required label="Day rate (in GBP)" prop="day_rate">
  136. <div class="el-input">
  137. <vue-numeric currency="£" separator="," :precision="2" v-model="joinForm.day_rate" class="el-input__inner" :disabled="true"></vue-numeric>
  138. </div>
  139. </el-form-item>
  140. </el-col>
  141. <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  142. <el-form-item required label="Languages" prop="languages">
  143. <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 5 }" placeholder="Your languages" v-model="joinForm.languages" />
  144. </el-form-item>
  145. </el-col>
  146. <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  147. <el-form-item required label="Availability" prop="availability">
  148. <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 5 }" placeholder="Your availability" v-model="joinForm.availability" />
  149. </el-form-item>
  150. </el-col>
  151. <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  152. <el-form-item required label="Education" prop="education">
  153. <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 5 }" placeholder="Your education" v-model="joinForm.education" />
  154. </el-form-item>
  155. </el-col>
  156. <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  157. <el-form-item required label="Memberships" prop="memberships">
  158. <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 5 }" placeholder="Your memberships" v-model="joinForm.memberships" />
  159. </el-form-item>
  160. </el-col>
  161. <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  162. <el-form-item required label="Professional experience" prop="professional_experience">
  163. <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 5 }" placeholder="Your professional experience" v-model="joinForm.professional_experience" />
  164. </el-form-item>
  165. </el-col>
  166. <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  167. <el-form-item required label="Past projects" prop="past_projects">
  168. <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 5 }" placeholder="Your past projects" v-model="joinForm.past_projects" />
  169. </el-form-item>
  170. </el-col>
  171. <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  172. <el-form-item required label="References" prop="references">
  173. <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 5 }" placeholder="Your references" v-model="joinForm.references" />
  174. </el-form-item>
  175. </el-col>
  176. </el-row>
  177. <el-row>
  178. <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  179. <h2>UPDATE PASSWORD</h2>
  180. </el-col>
  181. <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
  182. <el-form-item label="New password (min 6 characters)" prop="pass">
  183. <el-input type="password" v-model="joinForm.password" auto-complete="off" placeholder="Create a password"></el-input>
  184. </el-form-item>
  185. </el-col>
  186. <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
  187. <el-form-item label="Confirm new password" prop="checkPass">
  188. <el-input type="password" v-model="joinForm.checkPass" auto-complete="off" placeholder="Confirm password"></el-input>
  189. </el-form-item>
  190. </el-col>
  191. </el-row>
  192. <el-row>
  193. <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
  194. <h2>UPDATE TERMS AND CONDITIONS</h2>
  195. </el-col>
  196. <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24" class="btn-group save-updates-btn upload-terms text-left" style="margin-top:15px;">
  197. <p class="pull-left fileName" v-if="user.terms">
  198. <svg-terms></svg-terms>
  199. <a :href="user.terms.path">
  200. {{user.terms.original_filename}}
  201. </a>
  202. <i class="el-icon-error" @click="removeTermsCondition(user.terms)"></i>
  203. </p>
  204. <terms-condition-upload
  205. :entity="user.terms"
  206. :parent-id="$store.state.id"
  207. :types="termsAcceptType"
  208. :uploadUrl="uploadUrl"
  209. @fileWasUploaded="termsUploaded"
  210. ></terms-condition-upload>
  211. </el-col>
  212. </el-row>
  213. <el-row>
  214. <el-col :xl="24" class="save-updates-btn">
  215. <el-button type="submit" :loading="saveUpdates_isLoading" @click.native="updateProfile('joinForm', $event)">SAVE UPDATES</el-button>
  216. </el-col>
  217. </el-row>
  218. </el-form>
  219. </div>
  220. </div>
  221. </template>
  222. <script>
  223. import store from '../../store'
  224. import router from '../../router'
  225. import axios from 'axios'
  226. import { Message } from 'element-ui'
  227. import * as config from '../../config'
  228. import termsConditionUpload from './terms-condition-upload'
  229. import termsSvg from '../../components/assets/svg-terms'
  230.  
  231. export default {
  232. beforeCreate () {
  233. if (!store.state.isLogged) {
  234. this.$router.push('/login')
  235. }
  236. },
  237. components: {
  238. 'terms-condition-upload': termsConditionUpload,
  239. 'svg-terms': termsSvg,
  240.  
  241. },
  242. computed: {
  243. uploadUrl() {
  244. return `${config.apiUrl}users/profile/terms-conditions`;
  245. },
  246. },
  247. data() {
  248. let validatePass = (rule, value, callback) => {
  249. if (value === '') {
  250. callback(new Error('Please input your password'));
  251. } else if(value.length < 6) {
  252. callback(new Error('Your password contains less than 6 characters'));
  253. }
  254. else {
  255. if (this.joinForm.checkPass !== '') {
  256. this.$refs.joinForm.validateField('checkPass');
  257. }
  258. callback();
  259. }
  260. };
  261. let validatePass2 = (rule, value, callback) => {
  262. if (value === '' && this.joinForm.password != '') {
  263. callback(new Error('Please input your password again'));
  264. } else if (value !== this.joinForm.password && this.joinForm.password != '' ) {
  265. callback(new Error('Your passwords don\'t match!'));
  266. } else {
  267. callback();
  268. }
  269. };
  270. let validateCompanyName = (rule, value, callback) => {
  271. if ((value === false || value === '')) {
  272. callback(new Error('Company name is required.'))
  273. } else {
  274. callback()
  275. }
  276. }
  277. return {
  278. joinForm: {
  279. email: '',
  280. password: '',
  281. checkPass: ''
  282. },
  283. rules: {
  284. first_name: [
  285. { required: true, message: 'First name is required' },
  286. ],
  287. last_name: [
  288. { required: true, message: 'Surname is required' }
  289. ],
  290. timezone: [
  291. { required: true, message: 'Timezone is required' }
  292. ],
  293. company_country_id: [
  294. { required: true, message: 'Country is required' }
  295. ],
  296. company_name: [
  297. { validator: validateCompanyName, required: true }
  298. ],
  299. hour_rate: [
  300. { required: true, message: 'Hourly rate is required' }
  301. ],
  302. day_rate: [
  303. { required: true, message: 'Day rate is required' }
  304. ],
  305. languages: [
  306. { required: true, message: 'Languages is required' }
  307. ],
  308. availability: [
  309. { required: true, message: 'Availability is required' }
  310. ],
  311. education: [
  312. { required: true, message: 'Education is required' }
  313. ],
  314. memberships: [
  315. { required: true, message: 'Memberships is required' }
  316. ],
  317. professional_experience: [
  318. { required: true, message: 'Professional experience is required' }
  319. ],
  320. past_projects: [
  321. { required: true, message: 'Past projects is required' }
  322. ],
  323. password: [
  324. { validator: validatePass, required: false }
  325. ],
  326. checkPass: [
  327. { validator: validatePass2, required: false }
  328. ]
  329. },
  330. item: {
  331. image: store.state.avatar
  332. },
  333. user: {
  334. first_name: store.state.firstName,
  335. last_name: store.state.lastName,
  336. email: store.state.email,
  337. group_ids: this.getGroupTagsIds(store.state.groups),
  338. tag_ids: this.getGroupTagsIds(store.state.tags, true),
  339. company_name: store.state.company_name,
  340. company_country_id: store.state.company_country_id,
  341. company_number: store.state.company_number,
  342. company_street: store.state.company_street,
  343. company_town: store.state.company_town,
  344. company_region: store.state.company_region,
  345. company_postcode: store.state.company_postcode,
  346. company_vat_registered: false,
  347. company_vat_no: store.state.company_vat_no,
  348. company_position: store.state.company_position,
  349. timezone: store.state.timezone,
  350. hour_rate: store.state.hour_rate ? parseInt(store.state.hour_rate) : '',
  351. day_rate: store.state.day_rate ? parseInt(store.state.day_rate) : '',
  352. languages: store.state.languages,
  353. availability: store.state.availability,
  354. professional_experience: store.state.experience,
  355. past_projects: store.state.past_projects,
  356. education: store.state.education,
  357. memberships: store.state.memberships,
  358. references: store.state.references,
  359. title: store.state.title,
  360. password: null,
  361. checkPass:null,
  362. terms: store.state.terms
  363. },
  364. changeImg: false,
  365. addImage_isLoading: false,
  366. saveUpdates_isLoading: false,
  367. companyCountries: [],
  368. groups: [],
  369. timezones: [],
  370. tags: [],
  371. companyCode: 'ALEGRANT2018',
  372. initIsLoading: true,
  373. termsAcceptType: null,
  374. genders: [
  375. {
  376. id: 1,
  377. value: 'Male'
  378. },
  379. {
  380. id: 2,
  381. value: 'Female'
  382. },
  383. {
  384. id: 3,
  385. value: 'Rather not say'
  386. }
  387. ],
  388. titles: [
  389. {
  390. id: 1,
  391. value: 'Mr.'
  392. },
  393. {
  394. id: 2,
  395. value: 'Mrs.'
  396. },
  397. {
  398. id: 3,
  399. value: 'Miss'
  400. },
  401. {
  402. id: 4,
  403. value: 'Ms'
  404. },
  405. {
  406. id: 5,
  407. value: 'Dr.'
  408. }
  409. ],
  410. }
  411. },
  412. created() {
  413. // Change window title
  414. this.fetchGroups();
  415. this.fetchExpert();
  416. this.fetchCountries();
  417. this.fetchTimezones();
  418. this.fetchTags();
  419. this.uploadAcceptTypes();
  420. document.title = this.$route.meta.title;
  421. this.joinForm = {...this.joinForm, ...this.user};
  422. this.joinForm.gender = store.state.gender
  423. },
  424. methods: {
  425. getGroupTagsIds(entityIds, isTag){
  426. let ids = [];
  427. _.each(entityIds, (entity) => {
  428. ids.push(entity.id);
  429. });
  430. return ids;
  431. },
  432. onFileChange(event) {
  433. this.addImage_isLoading = true;
  434. let files = event.target.files || event.dataTransfer.files;
  435. if (!files.length)
  436. return;
  437. this.createImage(this.item, files[0]);
  438. },
  439. createImage(item, file) {
  440. let image = new Image();
  441. let reader = new FileReader();
  442. let self = this;
  443.  
  444. reader.onload = (e) => {
  445. item.image = e.target.result;
  446. };
  447. this.changeImg = true;
  448. reader.readAsDataURL(file);
  449.  
  450. let formData = new FormData();
  451. formData.append("avatar", file);
  452. axios({
  453. method: 'post',
  454. url: config.apiUrl + 'users/profile/avatar',
  455. headers: {
  456. ApiKey: config.apiKey,
  457. Authorization: store.state.token,
  458. 'Content-Type': 'multipart/form-data'
  459. },
  460. data: formData
  461. }).then(response => {
  462. self.addImage_isLoading = false;
  463. store.commit('CHANGE_AVATAR', response.data.avatar);
  464. Message.success('Your Avatar is updated successfully')
  465. });
  466. },
  467. updateProfile(formName, e) {
  468. e.preventDefault();
  469. this.saveUpdates_isLoading = true;
  470. let self = this;
  471. this.$refs[formName].validate((valid) => {
  472.  
  473. if (valid) {
  474. let params = {
  475. first_name: this.joinForm.first_name,
  476. last_name: this.joinForm.last_name,
  477. email: this.joinForm.email,
  478. timezone: this.joinForm.timezone,
  479. company_country_id: this.joinForm.company_country_id,
  480. group_ids: this.user.group_ids,
  481. tag_ids: this.user.tag_ids,
  482. has_company: this.joinForm.has_company,
  483. company_name: this.joinForm.company_name,
  484. company_position: this.joinForm.company_position,
  485. company_town: this.joinForm.company_town,
  486. company_region: this.joinForm.company_region,
  487. company_postcode: this.joinForm.company_postcode,
  488. company_vat_registered: this.joinForm.company_vat_registered,
  489. company_vat_no: this.joinForm.company_vat_no,
  490. hour_rate: store.state.hour_rate ? parseInt(store.state.hour_rate) : '',
  491. day_rate: store.state.day_rate ? parseInt(store.state.day_rate) : '',
  492. languages: this.joinForm.languages,
  493. availability: this.joinForm.availability,
  494. education: this.joinForm.education,
  495. memberships: this.joinForm.memberships,
  496. professional_experience: this.joinForm.professional_experience,
  497. past_projects: this.joinForm.past_projects,
  498. references: this.joinForm.references,
  499. title: this.joinForm.title,
  500. company_street: this.joinForm.street,
  501. password: this.joinForm.password ? this.joinForm.password : '',
  502. password_confirmation:this.joinForm.checkPass ? this.joinForm.checkPass : '',
  503. };
  504. axios({
  505. method: 'post',
  506. url: config.apiUrl + 'users/profile',
  507. headers: {
  508. ApiKey: config.apiKey,
  509. Authorization: store.state.token,
  510. },
  511. data: params
  512. }).then(response => {
  513. self.saveUpdates_isLoading = false
  514. store.commit('LOGIN_USER', response.data);
  515. Message.success('Your Profile is updated successfully')
  516. }).catch(error => {
  517. self.saveUpdates_isLoading = false;
  518. if (error.response && error.response.status == 422 && error.response.data) {
  519. _.each(error.response.data.errors, function (obj, index) {
  520. Message.error(obj[0])
  521. });
  522. } else {
  523. Message.error('An error occurred, please try again later.')
  524. }
  525. });
  526. } else {
  527. self.saveUpdates_isLoading = false
  528. console.log('form is not valid');
  529. }
  530. });
  531. },
  532. fetchGroups() {
  533. axios({
  534. method: 'get',
  535. url: config.apiUrl + 'groups',
  536. headers: {
  537. ApiKey: config.apiKey,
  538. },
  539. params: {
  540. is_joinable: 1,
  541. is_public: 0,
  542. per_page: 9999,
  543. page: 1
  544. }
  545. }).then(response => {
  546. this.groups.push(response.data.data)
  547. })
  548. },
  549. uploadAcceptTypes() {
  550. const vm = this;
  551. vm.termsAcceptType = ['application/*'];
  552. },
  553. fetchCountries() {
  554. let url = `${config.apiUrl}companies/countries?company_code=${this.companyCode}`
  555. axios({
  556. method: 'get',
  557. url: url,
  558. headers: {
  559. ApiKey: config.apiKey,
  560. },
  561. }).then(response => {
  562. this.companyCountries.push(response.data.data)
  563. })
  564. },
  565. fetchTimezones () {
  566. axios({
  567. method: 'get',
  568. url: config.apiUrl + 'timezones',
  569. headers: {
  570. ApiKey: config.apiKey,
  571. }
  572. }).then(response => {
  573. this.timezones.push(response.data)
  574. })
  575. },
  576. fetchTags () {
  577. axios({
  578. method: 'get',
  579. url: config.apiUrl + 'tags',
  580. headers: {
  581. ApiKey: config.apiKey,
  582. },
  583. params: {
  584. is_generic: true,
  585. per_page: 9999,
  586. page: 1,
  587. order_by: 'name',
  588. order: 'asc'
  589. }
  590. }).then(response => {
  591. this.tags.push(response.data.data)
  592. })
  593. },
  594. isInitialLoadComplete () {
  595. if (this.companyCountries.length > 0 && this.groups.length > 0 && this.timezones.length > 0 && this.tags.length > 0) {
  596. this.initIsLoading = false
  597. }
  598. },
  599. termsUploaded(response) {
  600. this.user.terms = response.data;
  601. },
  602. removeTermsCondition(terms) {
  603. let vm = this
  604. let url = `${config.apiUrl}users/profile/delete-terms-conditions`
  605. axios({
  606. method: 'delete',
  607. url: url,
  608. params: {
  609. id: terms.id
  610. },
  611. headers: {
  612. ApiKey: config.apiKey,
  613. Authorization: store.state.token,
  614. 'Content-Type': 'multipart/form-data'
  615. },
  616. }).then(response => {
  617. vm.user.terms = null;
  618. store.commit('RESET_TERMS');
  619. })
  620. },
  621. fetchExpert() {
  622. const vm = this;
  623. axios({
  624. method: 'get',
  625. url: `${config.apiUrl}experts/${store.state.id}`,
  626. headers: {
  627. ApiKey: config.apiKey,
  628. Authorization: store.state.token
  629. },
  630. }).then(response => {
  631. if(response.data) {
  632. vm.joinForm = response.data;
  633. vm.joinForm.group_ids = this.getGroupTagsIds(store.state.groups);
  634. vm.joinForm.tag_ids = this.getGroupTagsIds(store.state.tags, true);
  635. vm.joinForm.professional_experience = store.state.experience;
  636. response.data.token = store.state.token;
  637. store.commit('LOGIN_USER', response.data);
  638. }
  639. }).catch(error => {
  640. Message.error('An error occured, please refresh the page.')
  641. });
  642. },
  643. },
  644. watch: {
  645. companyCountries () {
  646. this.isInitialLoadComplete()
  647. },
  648. groups () {
  649. this.isInitialLoadComplete()
  650. },
  651. tags () {
  652. this.isInitialLoadComplete()
  653. },
  654. timezones () {
  655. this.isInitialLoadComplete()
  656. },
  657. }
  658. }
  659. </script>
Add Comment
Please, Sign In to add comment