You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

703 lines
23 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <client-only>
  3. <div
  4. class="purchaser-info tw-p-5 tw-mb-[20px] tw-bg-white tw-rounded-xl"
  5. >
  6. <div class="tw-flex tw-flex-row tw-justify-between tw-items-center">
  7. <h3
  8. :class="[
  9. 'collapse',
  10. 't16',
  11. 'tw-relative',
  12. 'tw-cursor-pointer',
  13. 'xl:tw-text-[18px]',
  14. show ? 'show' : 'hide',
  15. disabled ? 'disabled' : '',
  16. disabled ? 'tw-text-neutrals-300' : 'tw-text-black',
  17. ]"
  18. @click="show = !show"
  19. >
  20. {{ $t("Purchaser Info") }}
  21. </h3>
  22. <div class="element content-status xl:tw-ml-[20px]">
  23. <span
  24. v-if="purchaserValidation == true"
  25. class="status-check-icon tw-inline-block tw-w-[30px] tw-h-[30px]"
  26. ></span>
  27. </div>
  28. </div>
  29. <Transition name="bounce">
  30. <div v-show="show">
  31. <div class="tw-mt-[32px] md:tw-ml-[60px]">
  32. <div class="element element-tabs tw-mb-[20px]">
  33. <button
  34. :class="[
  35. 'tw-transition',
  36. 'tw-btn-md',
  37. 'tw-border',
  38. 'tw-border-solid',
  39. 'tw-border-neutrals-300',
  40. 'tw-px-[30px]',
  41. ' tw-py-[9.5px]',
  42. ' tw-rounded-2xl',
  43. infoType == 'Company'
  44. ? 'tw-bg-neutrals-800 tw-text-neutrals-0'
  45. : 'tw-bg-neutrals-0 tw-text-neutrals-300',
  46. ]"
  47. @click="$emit('type', 'Company')"
  48. >
  49. {{ $t('Company')}}
  50. </button>
  51. <button
  52. :class="[
  53. 'tw-transition',
  54. 'tw-btn-md',
  55. 'tw-border',
  56. 'tw-border-solid',
  57. 'tw-border-neutrals-300',
  58. 'tw-px-[30px]',
  59. ' tw-py-[9.5px]',
  60. ' tw-rounded-2xl',
  61. infoType == 'Individual'
  62. ? 'tw-bg-neutrals-800 tw-text-neutrals-0'
  63. : 'tw-bg-neutrals-0 tw-text-neutrals-300',
  64. ]"
  65. @click="$emit('type', 'Individual')"
  66. >
  67. {{ $t('Individual')}}
  68. </button>
  69. </div>
  70. <div v-show="infoType == 'Individual'">
  71. <div
  72. class="element element-form tw-grid tw-grid-cols-1 tw-gap-[10px] md:tw-grid-cols-2 md:tw-gap-x-[60px] md:tw-gap-y-[20px] md:tw-max-w-[580px]"
  73. >
  74. <div class="element">
  75. <elementInput
  76. :input="{
  77. id: 'FirstName',
  78. label: 'First Name',
  79. required: true,
  80. type: 'text',
  81. }"
  82. :default="userData.first_name"
  83. :validation="validation.first_name"
  84. @change="userData.first_name = $event"
  85. ></elementInput>
  86. </div>
  87. <div class="element">
  88. <elementInput
  89. :input="{
  90. id: 'LastName',
  91. label: 'Last Name',
  92. required: true,
  93. type: 'text',
  94. }"
  95. :default="userData.last_name"
  96. :validation="validation.last_name"
  97. @change="userData.last_name = $event"
  98. ></elementInput>
  99. </div>
  100. <div class="element">
  101. <elementInput
  102. :input="{
  103. id: 'ContactEmail',
  104. label: 'Contact Email',
  105. required: true,
  106. type: 'email',
  107. }"
  108. :default="userData.email"
  109. :validation="validation.email"
  110. @change="userData.email = $event"
  111. >
  112. </elementInput>
  113. </div>
  114. <div class="element">
  115. <label class="tw-block tw-mb-[10px]"
  116. ><span
  117. >{{ $t("Phone") }}<span class="required">*</span></span
  118. ></label
  119. >
  120. <div class="tw-grid tw-grid-cols-[120px_auto] tw-gap-[5px]">
  121. <!-- <vue-country-code
  122. class="d-none"
  123. @onSelect="onSelect"
  124. v-model="userData.country_code"
  125. :countryCode.sync="userData.country_code"
  126. enabldCountryCode
  127. :enabledFlags="false"
  128. ></vue-country-code> -->
  129. <elementCountryCodeSelect :select="{
  130. required: true,
  131. }" :userCodeSelect="userData.phone_code" :validation="validation.phone_code" @returnCode = "getReturnCode"></elementCountryCodeSelect>
  132. <!-- <vue-phone-number-input
  133. color="#e5e5e5"
  134. :border-radius="5"
  135. error-color="#ef5a5a"
  136. valid-color="#e5e5e5"
  137. :error="error"
  138. required
  139. no-flags
  140. no-example
  141. :validation="validation.phone_number"
  142. v-model="userData.phone_number"
  143. ></vue-phone-number-input> -->
  144. <vue-phone-number-input v-model="userData.phone_number" :validation="validation.phone_number" color="#E5e5e5" error-color="#ef5a5a"
  145. valid-color="#e5e5e5"
  146. :error="error" :border-radius="5"
  147. no-flags :no-country-selector="true" no-example @update="getPhoneData" :translations="translateOption">
  148. </vue-phone-number-input></div>
  149. </div>
  150. <div class="element">
  151. <elementSelect
  152. :select="{
  153. id: 'Country',
  154. label: 'Country/Region',
  155. required: true,
  156. }"
  157. :selectList="countryOptions"
  158. :default="userData.country"
  159. :validation="validation.country"
  160. @change="userData.country = $event"
  161. ></elementSelect>
  162. </div>
  163. <div class="element md:tw-col-span-2 tw-mt-[30px]">
  164. <elementCheckBox
  165. :input="{
  166. id: 'SaveInfo',
  167. label: 'Update personal info in your account',
  168. }"
  169. @update="updatePersonalInfo = $event"
  170. ></elementCheckBox>
  171. </div>
  172. </div>
  173. </div>
  174. <div v-show="infoType == 'Company'">
  175. <div
  176. class="element element-form tw-grid tw-grid-cols-1 tw-gap-y-[20px]"
  177. >
  178. <div
  179. class="element element-button-group tw-flex-wrap tw-mx-[8px]"
  180. >
  181. <Company ref="ref_company" :countryOptions="countryOptions"></Company>
  182. <!-- <button
  183. v-for="(item, index) in userCompanyList"
  184. :key="index"
  185. :class="[
  186. 'tw-transition',
  187. 'tw-btn-md',
  188. 'tw-text-[14px]',
  189. 'tw-leading-[18px]',
  190. 'tw-text-complementary-1',
  191. 'tw-bg-neutrals-0',
  192. 'tw-px-[12px]',
  193. 'tw-py-[11px]',
  194. 'tw-mx-[8px]',
  195. 'tw-mb-[16px]',
  196. 'tw-rounded-2xl',
  197. 'tw-border tw-border-solid',
  198. 'tw-bg-complementary-3',
  199. activeLabel == index + 1
  200. ? 'tw-border-complementary-1 tw-bg-complementary-1/20'
  201. : 'tw-border-transparent',
  202. ]"
  203. @click="onLabelClick(index + 1, item)"
  204. >
  205. {{ item.company_name }}
  206. </button>
  207. <button
  208. class="btn-add-icon tw-transition tw-btn-md tw-text-[14px] tw-leading-[18px] tw-text-complementary-1 tw-bg-complementary-3 tw-pr-[12px] tw-pl-[36px] tw-py-[11px] tw-mx-[8px] tw-mb-[16px] tw-rounded-[10px]"
  209. @click="$modal.show('add-modal')"
  210. >
  211. {{ $t("Add") }}
  212. </button> -->
  213. </div>
  214. <!-- <div class="company-info-list">
  215. <template v-for="(item, index) in userCompanyList">
  216. <div
  217. :key="index"
  218. v-if="index + 1 === activeLabel"
  219. class="tw-grid tw-grid-cols-1 tw-gap-y-[16px]"
  220. >
  221. <div
  222. class="element tw-grid tw-grid-cols-[140px_auto] tw-gap-x-[12px]"
  223. >
  224. <div class="label t14 tw-font-bold">
  225. {{ $t("Company Name") }}
  226. </div>
  227. <div class="content tw-body-4">
  228. {{ item.company_name }}
  229. </div>
  230. </div>
  231. <div
  232. class="element tw-grid tw-grid-cols-[140px_auto] tw-gap-x-[12px]"
  233. >
  234. <div class="label t14 tw-font-bold">
  235. {{ $t("Tax Number") }}
  236. </div>
  237. <div class="content tw-body-4">
  238. {{ item.company_tax_no }}
  239. </div>
  240. </div>
  241. <div
  242. class="element tw-grid tw-grid-cols-[140px_auto] tw-gap-x-[12px]"
  243. >
  244. <div class="label t14 tw-font-bold">
  245. {{ $t("Street Address") }}
  246. </div>
  247. <div class="content tw-body-4">
  248. {{ item.company_address1 }}{{ item.company_address2 }}
  249. </div>
  250. </div>
  251. <div
  252. class="element tw-grid tw-grid-cols-[140px_auto] tw-gap-x-[12px]"
  253. >
  254. <div class="label t14 tw-font-bold">{{ $t("City") }}</div>
  255. <div class="content tw-body-4">
  256. {{ item.company_city }}
  257. </div>
  258. </div>
  259. <div
  260. class="element tw-grid tw-grid-cols-[140px_auto] tw-gap-x-[12px]"
  261. >
  262. <div class="label t14 tw-font-bold">
  263. {{ $t("State/Province") }}
  264. </div>
  265. <div class="content tw-body-4">
  266. {{ item.company_state }}
  267. </div>
  268. </div>
  269. <div
  270. class="element tw-grid tw-grid-cols-[140px_auto] tw-gap-x-[12px]"
  271. >
  272. <div class="label t14 tw-font-bold">
  273. {{ $t("Country") }}
  274. </div>
  275. <div class="content tw-body-4">
  276. {{ item.company_country_name }}
  277. </div>
  278. </div>
  279. <div
  280. class="element tw-grid tw-grid-cols-[140px_auto] tw-gap-x-[12px]"
  281. >
  282. <div class="label t14 tw-font-bold">
  283. {{ $t("ZIP/Postal Code") }}
  284. </div>
  285. <div class="content tw-body-4">
  286. {{ item.company_zipcode }}
  287. </div>
  288. </div>
  289. <button
  290. class="btn-edit-icon tw-w-[28px] tw-h-[28px]"
  291. @click="$modal.show('edit-modal')"
  292. ></button>
  293. </div>
  294. </template>
  295. </div> -->
  296. </div>
  297. </div>
  298. <div class="element tw-mt-[40px] tw-text-right">
  299. <button
  300. class="tw-transition tw-btn-md tw-bg-primary-1 tw-px-[30px] tw-py-[9.5px] tw-rounded-2xl hover:tw-bg-primary-2"
  301. @click="updatePurchaserInfo(false)"
  302. >
  303. {{ $t("Next") }}
  304. </button>
  305. </div>
  306. </div>
  307. </div>
  308. </Transition>
  309. </div>
  310. </client-only>
  311. </template>
  312. <script>
  313. import elementInput from "@/components/newComponent/form/ElementInput";
  314. import elementSelect from "@/components/newComponent/form/ElementSelect";
  315. import elementCheckBox from "@/components/newComponent/form/ElementCheckBox";
  316. import Company from "@/components/service/Company";
  317. import elementCountryCodeSelect from "@/components/newComponent/form/ElementCountryCodeSelect.vue";
  318. import { IsNumber } from "~/utils/common";
  319. import is from "is_js";
  320. export default {
  321. name: "PurchaserInfo",
  322. props: {
  323. // userCompanyList: {
  324. // type: Array,
  325. // },
  326. countryOptions: {
  327. type: Array,
  328. },
  329. infoType: {
  330. type: String,
  331. },
  332. bookingDetail_Validation: {
  333. type: Boolean,
  334. },
  335. },
  336. components: {
  337. elementInput,
  338. elementSelect,
  339. elementCheckBox,
  340. Company,
  341. elementCountryCodeSelect,
  342. is,
  343. },
  344. data() {
  345. return {
  346. show: false,
  347. disabled: false,
  348. completed: false,
  349. userData: {
  350. first_name: "",
  351. last_name: "",
  352. email: "",
  353. phone_number: "",
  354. country: "0",
  355. phone_code: "",
  356. UserCompany: [],
  357. },
  358. updatePersonalInfo: false,
  359. userContactList: [],
  360. activeLabel: 0,
  361. Individual: {
  362. FirstName: "",
  363. LastName: "",
  364. Email: "",
  365. phone_code: "",
  366. phone_number: "",
  367. Country: "",
  368. },
  369. Company: {
  370. company_name: "",
  371. unified_number: "",
  372. company_address: "",
  373. city_: "",
  374. state_or_province: "",
  375. country: "0",
  376. postal_code: "",
  377. },
  378. validation: {
  379. first_name: true,
  380. last_name: true,
  381. email: true,
  382. phone_code: true,
  383. phone_number: true,
  384. country: true,
  385. },
  386. errors: null,
  387. purchaserValidation: false,
  388. error: false,
  389. isValid: false,
  390. translateOption: {
  391. countrySelectorLabel: this.$t("country code"),
  392. phoneNumberLabel: this.$t("phone number"),
  393. },
  394. };
  395. },
  396. async created() {
  397. if (this.$auth.loggedIn) {
  398. await this.getUser();
  399. }
  400. },
  401. watch: {
  402. // userCompanyList: {
  403. // handler: function () {
  404. // if (this.userCompanyList) {
  405. // this.activeLabel = this.userCompanyList.length > 0 ? 1 : 0;
  406. // this.Company.company_name = this.userCompanyList[0].company_name;
  407. // this.Company.company_tax_no = this.userCompanyList[0].company_tax_no;
  408. // this.Company.company_address1 =
  409. // this.userCompanyList[0].company_address1;
  410. // this.Company.company_address2 =
  411. // this.userCompanyList[0].company_address2;
  412. // this.Company.company_city = this.userCompanyList[0].company_city;
  413. // this.Company.company_state = this.userCompanyList[0].company_state;
  414. // this.Company.company_country =
  415. // this.userCompanyList[0].company_country_name;
  416. // this.Company.company_zipcode =
  417. // this.userCompanyList[0].company_zipcode;
  418. // }
  419. // },
  420. // },
  421. bookingDetail_Validation: {
  422. handler: function () {
  423. if (this.bookingDetail_Validation) {
  424. this.show = true;
  425. } else {
  426. this.show = false;
  427. }
  428. },
  429. },
  430. purchaserValidation: {
  431. handler: function () {
  432. if (this.purchaserValidation) {
  433. this.show = false;
  434. }
  435. },
  436. },
  437. },
  438. methods: {
  439. getReturnCode(code){
  440. this.userData.phone_code = code;
  441. },
  442. getPhoneData(phoneData) {
  443. // this.userData.phone_code = phoneData.countryCode;
  444. // //this.userData.PhoneCode = phoneData.countryCallingCode;
  445. // this.error = phoneData.isValid = true ? false : true;
  446. this.validation.phone_number = phoneData.isValid;
  447. },
  448. // onLabelClick(label, item) {
  449. // this.activeLabel = label;
  450. // this.$emit("active", this.activeLabel);
  451. // this.Company.company_name = item.company_name;
  452. // this.Company.company_tax_no = item.company_tax_no;
  453. // this.Company.company_address1 = item.company_address1;
  454. // this.Company.company_address2 = item.company_address2;
  455. // this.Company.company_city = item.company_city;
  456. // this.Company.company_state = item.company_state;
  457. // this.Company.company_country = item.company_country_name;
  458. // this.Company.company_zipcode = item.company_zipcode;
  459. // },
  460. async getUser() {
  461. await this.$axios
  462. .get(`/trending/api/Onsite/MemberInfo`)
  463. .then((response) => {
  464. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  465. let data = response.data.DATA.rel
  466. if(data){
  467. this.userData.first_name = data.FirstName;
  468. this.userData.last_name = data.LastName;
  469. this.userData.email = data.Email;
  470. this.userData.phone_number = data.Phone;
  471. this.userData.country = data.CountryID;
  472. this.userData.phone_code = data.PhoneCode;
  473. }
  474. }
  475. })
  476. .catch((err) => {
  477. console.log(err);
  478. });
  479. },
  480. updateIndividual() {
  481. const patchData = JSON.parse(JSON.stringify(this.userData));
  482. let params = {
  483. FirstName: patchData.first_name,
  484. LastName: patchData.last_name,
  485. Email: patchData.email,
  486. Phone: patchData.phone_number,
  487. CountryID: patchData.country,
  488. PhoneCode: patchData.phone_code,
  489. }
  490. this.$axios
  491. .post(
  492. `/trending/api/Onsite/Member`,
  493. params
  494. )
  495. .then((result) => {
  496. console.log(result);
  497. })
  498. .catch((err) => {
  499. console.log(err);
  500. });
  501. },
  502. updateCompany() {
  503. let patchData = this.$refs.ref_company.getFormData();
  504. if(patchData.company_name=="" && patchData.unified_number=="" && patchData.city_ ==""
  505. && patchData.company_address =="" && patchData.state_or_province=="" && (patchData.country=="" || patchData.country=="0") && patchData.postal_code==""){
  506. return false;
  507. }
  508. let params = {
  509. CompanyName: patchData.company_name,
  510. TaxNumber: patchData.unified_number,
  511. CityName: patchData.city_,
  512. Street1: patchData.company_address,
  513. StateName: patchData.state_or_province,
  514. CountryID: patchData.country,
  515. ZipCode: patchData.postal_code,
  516. }
  517. this.$axios
  518. .post(
  519. `/trending/api/Onsite/Company`,
  520. params
  521. )
  522. .then((result) => {
  523. console.log(result);
  524. })
  525. .catch((err) => {
  526. console.log(err);
  527. });
  528. },
  529. updatePurchaserInfo(isUpdate) {
  530. switch (this.infoType) {
  531. case "Individual":
  532. this.$emit("type", "Individual");
  533. if(this.updatePersonalInfo){
  534. this.validators();
  535. if (this.validators()) {
  536. // this.$emit("type", "Individual");
  537. this.$emit("individual", this.userData);
  538. this.purchaserValidation = true;
  539. this.$emit("purchaserInfo_validation", this.purchaserValidation);
  540. } else {
  541. this.purchaserValidation = false;
  542. this.$emit("purchaserInfo_validation", this.purchaserValidation);
  543. }
  544. }else{
  545. this.purchaserValidation = true;
  546. this.$emit("purchaserInfo_validation", this.purchaserValidation);
  547. }
  548. break;
  549. case "Company":
  550. this.$emit("type", "Company");
  551. this.Company = this.$refs.ref_company.getFormData();
  552. this.$emit("company", this.Company);
  553. this.purchaserValidation = true;
  554. this.$emit("purchaserInfo_validation", this.purchaserValidation);
  555. break;
  556. }
  557. if(isUpdate){
  558. if(this.updatePersonalInfo){
  559. if (this.validators()) {
  560. this.updateIndividual();
  561. }
  562. }
  563. this.updateCompany();
  564. }
  565. },
  566. validators() {
  567. if (is.empty(this.userData.first_name)) {
  568. this.validation.first_name = false;
  569. } else {
  570. this.validation.first_name = true;
  571. }
  572. if (is.empty(this.userData.last_name)) {
  573. this.validation.last_name = false;
  574. } else {
  575. this.validation.last_name = true;
  576. }
  577. if (is.empty(this.userData.email) || is.not.email(this.userData.email)) {
  578. this.validation.email = false;
  579. } else {
  580. this.validation.email = true;
  581. }
  582. if (
  583. is.empty(this.userData.phone_number) ||
  584. IsNumber(this.userData.phone_number) == false
  585. ) {
  586. this.validation.phone_number = false;
  587. this.error = true;
  588. } else {
  589. this.validation.phone_number = true;
  590. this.error = false;
  591. }
  592. if (is.empty(this.userData.country) || this.userData.country == "0") {
  593. this.validation.country = false;
  594. } else {
  595. this.validation.country = true;
  596. }
  597. this.errors = Object.entries(this.validation).filter(
  598. (e) => e[1] == false
  599. );
  600. if (this.errors.length > 0) {
  601. this.purchaserValidation = false;
  602. return false;
  603. } else {
  604. return true;
  605. }
  606. },
  607. onSelect(data){
  608. // debugger
  609. // this.userData.country_code = data.dialCode;
  610. }
  611. },
  612. };
  613. </script>
  614. <style lang="scss" scoped>
  615. .collapse {
  616. &::before {
  617. content: "";
  618. display: inline-block;
  619. position: relative;
  620. left: 0;
  621. top: 0;
  622. background-image: url("~/assets/svg/down-arrow.svg");
  623. background-repeat: no-repeat;
  624. background-position: center;
  625. background-size: 100%;
  626. width: 16px;
  627. height: 10px;
  628. margin-right: 40px;
  629. transform: rotate(-90deg);
  630. transition: all 0.2s linear;
  631. }
  632. &.disabled {
  633. pointer-events: none;
  634. &::before {
  635. background-image: url("~/assets/svg/down-arrow-disabled.svg");
  636. }
  637. }
  638. &.show {
  639. &::before {
  640. transform: rotate(0);
  641. transition: all 0.2s linear;
  642. }
  643. }
  644. }
  645. .btn-add-icon {
  646. background-image: url("~/assets/svg/plus-blue.svg");
  647. background-repeat: no-repeat;
  648. background-position: left 12px center;
  649. background-size: 16px 16px;
  650. }
  651. .btn-edit-icon {
  652. background-image: url("~/assets/svg/edit-info.svg");
  653. background-repeat: no-repeat;
  654. background-position: center;
  655. background-size: 100%;
  656. }
  657. .bounce-enter-active {
  658. animation: bounce-in 0.3s ease-out;
  659. }
  660. .bounce-leave-active {
  661. animation: bounce-in 0.3s cubic-bezier(1, 0.5, 0.8, 1) reverse;
  662. }
  663. @keyframes bounce-in {
  664. 0% {
  665. opacity: 0;
  666. transform: translateY(-10px);
  667. }
  668. 50% {
  669. opacity: 0.5;
  670. transform: translateY(-5px);
  671. }
  672. 100% {
  673. opacity: 1;
  674. transform: translateY(0);
  675. }
  676. }
  677. .status-check-icon {
  678. background-image: url("~/assets/svg/status-check.svg");
  679. background-size: 100%;
  680. background-repeat: no-repeat;
  681. background-position: center;
  682. }
  683. :deep(.input-tel__input) {
  684. height: 44px !important;
  685. padding-left: 13px !important;
  686. }
  687. </style>