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.

439 lines
16 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
  1. <template>
  2. <div class="setting xl:tw-max-w-[1246px] xl:tw-mx-auto">
  3. <div class="xl:tw-flex xl:tw-justify-between xl:tw-items-start">
  4. <userSidebar :userData="userData" :firstName="firstName" :lastName="lastName" class="tw-hidden xl:tw-block">
  5. </userSidebar>
  6. <!-- <div class="xl:tw-hidden"></div> -->
  7. <div class="tw-bg-white xl:tw-p-[30px] xl:tw-rounded-[20px] xl:tw-min-w-[900px] xl:tw-max-w-[900px]">
  8. <div class="tw-text-[20px] tw-font-bold tw-text-base-primary tw-mb-[20px] md:t24 md:tw-mb-[30px]">
  9. <two-dots class="tw-mr-[30px]"></two-dots>{{ $t("userProfile.setting") }}
  10. </div>
  11. <div class="tw-mb-[30px] md:tw-max-w-[392px]">
  12. <div class="tw-body-2 tw-font-bold tw-text-base-primary tw-mb-[15px] md:t16">
  13. {{ $t('userProfile.account') }}
  14. </div>
  15. <input type="text"
  16. class="tw-h-[40px] tw-w-full tw-border tw-bg-white tw-border-neutral-200 tw-border-solid tw-px-[20px] tw-py-[10px] tw-rounded-[5px] disabled:tw-text-base-disable"
  17. :value="userData.Account" disabled />
  18. </div>
  19. <Transition name="bounce">
  20. <div v-show="SSOShow == 2" :class="['tw-mb-[50px] md:tw-mb-[30px]',SSOShow == 2 ? '':'tw-hidden']">
  21. <div class="tw-body-2 tw-font-medium tw-text-base-primary tw-mb-[15px] md:t16">
  22. {{ $t('userProfile.manageSSO')}}
  23. </div>
  24. <div class="md:tw-flex md:tw-flex-row">
  25. <div
  26. class="tw-w-full tw-border tw-border-solid tw-border-neutral-200 tw-rounded-[10px] tw-grid tw-grid-cols-[auto_71px] tw-items-center tw-gap-[50px] tw-px-[30px] tw-py-[14px] tw-mb-[20px] md:tw-mb-0 md:tw-mr-[20px] md:tw-py-[30px]">
  27. <div class="tw-text-[16px] tw-text-base-primary md:tw-text-[14px]">
  28. Facebook
  29. </div>
  30. <button v-if="facebook.social_schema" @click="openModal('facebook')"
  31. class="tw-bg-warning-background tw-text-warning-default tw-rounded-[12px] tw-px-[16px] tw-py-[9px] tw-whitespace-nowrap">
  32. {{$t('userProfile.SSOUnLink')}}
  33. </button>
  34. <button v-else @click="facebookLogin"
  35. class="tw-bg-warning-default tw-text-white tw-rounded-[12px] tw-px-[16px] tw-py-[9px]">
  36. {{$t('userProfile.SSOLink')}}
  37. </button>
  38. </div>
  39. <div
  40. class="tw-w-full tw-border tw-border-solid tw-border-neutral-200 tw-rounded-[10px] tw-grid tw-grid-cols-[auto_90px] tw-items-center tw-gap-[50px] tw-px-[30px] tw-py-[14px] md:tw-py-[30px]">
  41. <div class="tw-text-[16px] tw-text-base-primary md:tw-text-[14px]">
  42. Google
  43. </div>
  44. <button v-if="google.social_schema" @click.prevent="openModal('google')"
  45. class="tw-bg-warning-background tw-text-warning-default tw-rounded-[12px] tw-px-[16px] tw-py-[9px]">
  46. {{$t('userProfile.SSOUnLink')}}
  47. </button>
  48. <button v-else @click="googleLogin"
  49. class="tw-bg-warning-default tw-text-white tw-rounded-[12px] tw-px-[16px] tw-py-[9px]">
  50. {{$t('userProfile.SSOLink')}}
  51. </button>
  52. </div>
  53. </div>
  54. </div>
  55. </Transition>
  56. <Transition name="bounce">
  57. <div>
  58. <div class="tw-body-2 tw-font-bold tw-text-base-primary tw-mb-[20px] md:t16 md:tw-mb-[15px]">
  59. {{$t('userProfile.resetPassword')}}
  60. </div>
  61. <div class="tw-mb-[20px] md:tw-max-w-[392px] md:tw-mb-[15px]">
  62. <div class="tw-text-[16px] tw-text-base-primary tw-mb-[6px] md:tw-text-[14px]">
  63. {{$t('userProfile.oldPassword')}}
  64. </div>
  65. <input v-model="userPass.user_old_pass" type="password"
  66. class="tw-h-[40px] tw-w-full tw-border tw-border-neutral-200 tw-border-solid tw-px-[20px] tw-py-[10px] tw-rounded-[5px]" />
  67. </div>
  68. <div class="tw-mb-[20px] md:tw-max-w-[392px] md:tw-mb-[15px]">
  69. <!-- <div
  70. class="tw-text-[16px] tw-text-base-primary tw-mb-[6px] md:tw-text-[14px]"
  71. >
  72. New password
  73. </div>
  74. <input
  75. type="text"
  76. class="tw-h-[40px] tw-w-full tw-border tw-border-neutral-200 tw-border-solid tw-px-[20px] tw-py-[10px] tw-rounded-[5px] tw-mb-[6px]"
  77. /> -->
  78. <div>
  79. <div class="tw-text-[16px] tw-text-base-primary tw-mb-[6px] md:tw-text-[14px]">
  80. {{$t('userProfile.newPassword')}}
  81. </div>
  82. <v-text-field v-model="userPass.user_new_pass" :append-icon="showPass ? 'mdi-eye' : 'mdi-eye-off'"
  83. @click:append="showPass = !showPass" @blur="checkPassword($event)"
  84. :type="showPass ? 'text' : 'password'" :rules="[rules.checkPassword, rules.require]" hide-details
  85. dense outlined validate-on-blur></v-text-field>
  86. </div>
  87. <div v-show="!isNewPassValid" class="tw-footer-body tw-w-full tw-leading-none tw-pt-1" :class="
  88. isNewPassValid
  89. ? 'tw-text-neutrals-400'
  90. : 'tw-text-error-default'
  91. ">
  92. {{ $t('userProfile.passwordsHint') }}
  93. </div>
  94. </div>
  95. <div class="tw-mb-[20px] md:tw-max-w-[392px] md:tw-mb-[15px]">
  96. <div>
  97. <div class="tw-text-[16px] tw-text-base-primary tw-mb-[6px] md:tw-text-[14px]">
  98. {{$t('userProfile.confirmPassword')}}
  99. </div>
  100. <v-text-field v-model="confirmPass" :append-icon="showConfirmPass ? 'mdi-eye' : 'mdi-eye-off'"
  101. @click:append="showConfirmPass = !showConfirmPass" :type="showConfirmPass ? 'text' : 'password'"
  102. :rules="[rules.checkConfirmPassword, rules.require]" dense outlined validate-on-blur></v-text-field>
  103. </div>
  104. <!-- <div
  105. class="tw-text-[16px] tw-text-base-primary tw-mb-[6px] md:tw-text-[14px]"
  106. >
  107. Confirm password
  108. </div>
  109. <input
  110. type="text"
  111. class="tw-h-[40px] tw-w-full tw-border tw-border-neutral-200 tw-border-solid tw-px-[20px] tw-py-[10px] tw-rounded-[5px] tw-mb-[6px]"
  112. />
  113. <img
  114. src="~/assets/svg/hidepassword.svg"
  115. class="tw-absolute tw-top-[717px] tw-right-[20px] md:tw-top-[621px] md:tw-left-[359px] xl:tw-left-[777px] xl:tw-top-[650px]"
  116. alt=""
  117. /> -->
  118. </div>
  119. </div>
  120. </Transition>
  121. <Transition name="bounce">
  122. <div
  123. :lass="['tw-mb-[64px] md:tw-flex md:tw-flex-row md:tw-items-center md:tw-mb-[40px]']">
  124. <button @click="resetPassword"
  125. class="tw-text-white tw-bg-primary-1 tw-text-[18px] tw-rounded-[16px] tw-w-full tw-py-[13px] tw-mb-[15px] md:tw-text-[16px] md:tw-w-fit md:tw-px-[16px] md:tw-py-[10px] md:tw-mr-[20px] md:tw-mb-0">
  126. {{$t('userProfile.resetPassword')}}
  127. </button>
  128. <button @click="cancel"
  129. class="tw-text-primary-1 tw-bg-white tw-text-[18px] tw-rounded-[16px] tw-w-full tw-py-[13px] md:tw-text-[16px] md:tw-w-fit md:tw-px-[16px] md:tw-py-[10px]">
  130. {{$t('userProfile.cancel')}}
  131. </button>
  132. </div>
  133. </Transition>
  134. <button @click="openDeleteModal()"
  135. class="tw-text-error-default tw-text-[16px] tw-underline tw-mt-[44px] md:tw-mt-[99px] xl:tw-mt-[39px]">
  136. {{$t('userProfile.deleteAccount')}}
  137. </button>
  138. </div>
  139. </div>
  140. <Transition name="bounce">
  141. <unLinkModal></unLinkModal>
  142. </Transition>
  143. <Transition name="bounce">
  144. <deleteAccountModal :userData="userData"></deleteAccountModal>
  145. </Transition>
  146. </div>
  147. </template>
  148. <script>
  149. import SavedExhibitions from "../../components/user/savedExhibitions.vue";
  150. import SavedExhibitionsDialog from "../../components/user/savedExhibitionsDialog.vue";
  151. import Setting from "../../components/user/Setting.vue";
  152. import SettingDialog from "../../components/user/settingDialog.vue";
  153. import CropImageDialog from "../../components/user/cropImageDialog.vue";
  154. import CompanyInfo from "../../components/user/companyInfo.vue";
  155. import CompanyInfoDialog from "../../components/user/companyInfoDialog.vue";
  156. import ContactInfo from "../../components/user/contactInfo.vue";
  157. import vClickOutside from "v-click-outside";
  158. import BookingList from "../../components/user/bookingList.vue";
  159. import TwoDots from "@/components/TwoDots";
  160. import userSidebar from "@/components/user/userSidebar.vue";
  161. import unLinkModal from "@/components/newComponent/modal/unLinkModal.vue";
  162. import deleteAccountModal from "@/components/newComponent/modal/deleteAccountModal.vue";
  163. export default {
  164. name: "setting",
  165. layout: "profile",
  166. directives: {
  167. clickOutside: vClickOutside.directive,
  168. },
  169. components: {
  170. SavedExhibitions,
  171. SavedExhibitionsDialog,
  172. Setting,
  173. SettingDialog,
  174. CropImageDialog,
  175. CompanyInfo,
  176. CompanyInfoDialog,
  177. ContactInfo,
  178. BookingList,
  179. TwoDots,
  180. userSidebar,
  181. unLinkModal,
  182. deleteAccountModal,
  183. },
  184. data() {
  185. return {
  186. google: {},
  187. facebook: {},
  188. deleteDialogActive: false,
  189. valid: false,
  190. showPass: false,
  191. showConfirmPass: false,
  192. userPass: {
  193. user_old_pass: "",
  194. user_new_pass: "",
  195. },
  196. isNewPassValid: true,
  197. firstName: "",
  198. lastName: "",
  199. userData: {},
  200. SSOShow: 0,
  201. confirmPass: "",
  202. deleteAccountImg: require("~/assets/img/deleteAccount.png"),
  203. rules: {
  204. require: (value) => !!value || this.$t("Required."),
  205. email: (v) =>
  206. /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/.test(
  207. v
  208. ) || this.$t("Invalid email"),
  209. checkPassword: (v) =>
  210. (/(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])/.test(v) &&
  211. v.length >= 8 &&
  212. v.length <= 20) ||
  213. this.$t(
  214. "Passwords must be 8-20 characters with at least 1 number, 1 lower case letter and 1 upper case letter"
  215. ),
  216. checkConfirmPassword: (v) =>
  217. this.confirmPass === this.userPass.user_new_pass ||
  218. this.$t("Your password and confirmation password do not match"),
  219. },
  220. };
  221. },
  222. created() {
  223. //this.geiApiDemo();
  224. this.fetchUserData();
  225. if (process.browser) {
  226. window.addEventListener("resize", this.handleResize);
  227. }
  228. //this.handleResize();
  229. },
  230. mounted() {
  231. this.$nextTick(() => {
  232. window.addEventListener("resize", this.onResize);
  233. });
  234. },
  235. destroyed() {
  236. if (process.browser) {
  237. window.removeEventListener("resize", this.handleResize);
  238. }
  239. },
  240. computed: {
  241. windowWidth() {
  242. if (process.client) {
  243. this.width = window.innerWidth;
  244. }
  245. return this.width;
  246. },
  247. },
  248. methods: {
  249. handleResize() {
  250. if (process.browser) {
  251. this.width = window.innerWidth;
  252. }
  253. },
  254. // geiApiDemo(){
  255. // this.$axios
  256. // .get(
  257. // `/trending/api/Members/Info`
  258. // )
  259. // .then((res) => {
  260. // console.log(JSON.stringify(res));
  261. // })
  262. // .catch((err) => {
  263. // console.log(err);
  264. // });
  265. // },
  266. fetchUserData() {
  267. this.$axios
  268. .get(
  269. `/trending/api/Members/Info`
  270. )
  271. .then((response) => {
  272. //console.log(JSON.stringify(response));
  273. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  274. let data = response.data.DATA.rel
  275. if(data){
  276. this.userData = data;
  277. //console.log("userData:" + this.userData);
  278. this.firstName = this.userData.FirstName;
  279. this.lastName = this.userData.LastName;
  280. // this.facebook =
  281. // res.data.UserSocialRelation.filter(
  282. // (item) => item.social_schema === "facebook"
  283. // )[0] || {};
  284. // this.google =
  285. // res.data.UserSocialRelation.filter(
  286. // (item) => item.social_schema === "google"
  287. // )[0] || {};
  288. // this.checkSSO();
  289. }
  290. }
  291. })
  292. .catch((error) => {
  293. console.log(error);
  294. });
  295. },
  296. removeSocialRelation(schema) {
  297. delete schema.social_id;
  298. this.$axios
  299. .put(
  300. `/member/users/social?jwt=${this.$auth.$storage.getUniversal("jwt").token || ""
  301. }`,
  302. schema
  303. )
  304. .then((result) => {
  305. this.$emit("refetch-user");
  306. })
  307. .catch((err) => {
  308. console.log(err);
  309. });
  310. this.$nextTick(() => {
  311. schema.social_schema === "google"
  312. ? (this.google = {})
  313. : (this.facebook = {});
  314. });
  315. },
  316. facebookLogin() {
  317. this.$auth.loginWith("facebook");
  318. },
  319. googleLogin() {
  320. this.$auth.loginWith("google");
  321. },
  322. resetPassword() {
  323. if (
  324. this.isNewPassValid &&
  325. this.userPass.user_old_pass !== this.userPass.user_new_pass
  326. ) {
  327. this.$axios
  328. .post(
  329. `/trending/api/Members/ResetNewPassword/?Password=${this.userPass.user_new_pass}`
  330. )
  331. .then((response) => {
  332. //(JSON.stringify(response));
  333. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  334. let data = response.data.DATA.rel
  335. if(data){
  336. this.$auth.$storage.removeUniversal("userPicture");
  337. this.$auth.$storage.removeUniversal("userLastName");
  338. this.$notify({
  339. type: "success",
  340. title: "Awesome!",
  341. text: "Your password has been updated successfully.",
  342. });
  343. setTimeout(() => {
  344. this.$auth.logout();
  345. this.$router.push(this.localePath("/user"));
  346. }, 4000)
  347. }
  348. }
  349. })
  350. .catch((error) => {
  351. console.log(error);
  352. });
  353. }
  354. },
  355. cancel(){
  356. this.userPass.user_old_pass = "",
  357. this.userPass.user_new_pass = "",
  358. this.confirmPass = ""
  359. },
  360. checkPassword(v) {
  361. const pass = v.target.value;
  362. this.isNewPassValid =
  363. /(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])/.test(pass) &&
  364. pass.length >= 8 &&
  365. pass.length <= 20;
  366. },
  367. checkSSO() {
  368. if (Object.keys(this.facebook).length == 0 && Object.keys(this.google).length == 0) {
  369. this.SSOShow = 1;
  370. } else {
  371. this.SSOShow = 2;
  372. }
  373. },
  374. openModal(type) {
  375. if (type == 'google') {
  376. if (Object.keys(this.facebook).length == 0) {
  377. this.$modal.show('unLinkModal');
  378. } else {
  379. this.removeSocialRelation(this.google);
  380. }
  381. }
  382. if (type == 'facebook') {
  383. if (Object.keys(this.google).length == 0) {
  384. this.$modal.show('unLinkModal');
  385. } else {
  386. this.removeSocialRelation(this.facebook);
  387. }
  388. }
  389. },
  390. openDeleteModal() {
  391. this.$modal.show('deleteAccountModal');
  392. }
  393. },
  394. };
  395. </script>
  396. <style scoped lang="scss">
  397. :deep(.v-text-field.v-text-field--enclosed .v-text-field__details) {
  398. padding: 0;
  399. margin: 0;
  400. }
  401. :deep(.v-messages__message) {
  402. font-size: 14px;
  403. }
  404. .v-text-field--outlined::v-deep {
  405. fieldset {
  406. border-color: #e5e5e5;
  407. }
  408. }
  409. .bounce-enter-active {
  410. animation: bounce-in 0.3s ease-out;
  411. }
  412. .bounce-leave-active {
  413. animation: bounce-in 0.3s cubic-bezier(1, 0.5, 0.8, 1) reverse;
  414. }
  415. @keyframes bounce-in {
  416. 0% {
  417. opacity: 0;
  418. transform: translateY(-10px);
  419. }
  420. 50% {
  421. opacity: 0.5;
  422. transform: translateY(-5px);
  423. }
  424. 100% {
  425. opacity: 1;
  426. transform: translateY(0);
  427. }
  428. }
  429. </style>