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.

318 lines
11 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
  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="tw-bg-white xl:tw-p-[30px] xl:tw-rounded-[20px] xl:tw-min-w-[900px] xl:tw-max-w-[900px]">
  7. <div class="tw-text-[20px] tw-font-bold tw-text-base-primary tw-mb-[20px] md:t24 md:tw-mb-[30px]">
  8. <two-dots class="tw-mr-[30px]"></two-dots>{{ $t("userProfile.setting") }}
  9. </div>
  10. <div class="tw-mb-[30px] md:tw-max-w-[392px]">
  11. <div class="tw-body-2 tw-font-bold tw-text-base-primary tw-mb-[15px] md:t16">
  12. {{ $t('userProfile.account') }}
  13. </div>
  14. <input type="text"
  15. 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"
  16. :value="userData.Account" disabled />
  17. </div>
  18. <Transition name="bounce">
  19. <div>
  20. <div class="tw-body-2 tw-font-bold tw-text-base-primary tw-mb-[20px] md:t16 md:tw-mb-[15px]">
  21. {{$t('userProfile.resetPassword')}}
  22. </div>
  23. <div class="tw-mb-[20px] md:tw-max-w-[392px] md:tw-mb-[15px]">
  24. <div class="tw-mb-[20px] md:tw-max-w-[392px] md:tw-mb-0">
  25. <div class="tw-text-[16px] tw-text-base-primary tw-mb-[6px] md:tw-text-[14px]">
  26. {{$t('userProfile.oldPassword')}}
  27. </div>
  28. <v-text-field type="password" v-model="userPass.user_old_pass" @blur="checkOldPassword($event)" :rules="[rules.checkPassword, rules.require]"
  29. hide-details dense outlined validate-on-blur></v-text-field>
  30. </div>
  31. <div v-show="!isOldPassValid" class="tw-footer-body tw-w-full tw-leading-none tw-pt-1" :class="
  32. isOldPassValid
  33. ? 'tw-text-neutrals-400'
  34. : 'tw-text-error-default'
  35. ">
  36. {{ $t('userProfile.passwordsHint') }}
  37. </div>
  38. </div>
  39. <div class="tw-mb-[20px] md:tw-max-w-[392px] md:tw-mb-[15px]">
  40. <div>
  41. <div class="tw-text-[16px] tw-text-base-primary tw-mb-[6px] md:tw-text-[14px]">
  42. {{$t('userProfile.newPassword')}}
  43. </div>
  44. <v-text-field v-model="userPass.user_new_pass" :append-icon="showPass ? 'mdi-eye' : 'mdi-eye-off'"
  45. @click:append="showPass = !showPass" @blur="checkPassword($event)"
  46. :type="showPass ? 'text' : 'password'" :rules="[rules.checkPassword, rules.require]" hide-details
  47. dense outlined validate-on-blur></v-text-field>
  48. </div>
  49. <div v-show="!isNewPassValid" class="tw-footer-body tw-w-full tw-leading-none tw-pt-1" :class="
  50. isNewPassValid
  51. ? 'tw-text-neutrals-400'
  52. : 'tw-text-error-default'
  53. ">
  54. {{ $t('userProfile.passwordsHint') }}
  55. </div>
  56. </div>
  57. <div class="tw-mb-[20px] md:tw-max-w-[392px] md:tw-mb-[15px]">
  58. <div>
  59. <div class="tw-text-[16px] tw-text-base-primary tw-mb-[6px] md:tw-text-[14px]">
  60. {{$t('userProfile.confirmPassword')}}
  61. </div>
  62. <v-text-field v-model="confirmPass" :append-icon="showConfirmPass ? 'mdi-eye' : 'mdi-eye-off'"
  63. @click:append="showConfirmPass = !showConfirmPass" :type="showConfirmPass ? 'text' : 'password'"
  64. :rules="[rules.checkConfirmPassword, rules.require]" dense outlined validate-on-blur></v-text-field>
  65. </div>
  66. </div>
  67. </div>
  68. </Transition>
  69. <Transition name="bounce">
  70. <div
  71. :lass="['tw-mb-[64px] md:tw-flex md:tw-flex-row md:tw-items-center md:tw-mb-[40px]']">
  72. <button @click="resetPassword"
  73. 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">
  74. {{$t('userProfile.resetPassword')}}
  75. </button>
  76. <button @click="cancel"
  77. 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]">
  78. {{$t('userProfile.cancel')}}
  79. </button>
  80. </div>
  81. </Transition>
  82. <button @click="openDeleteModal()"
  83. class="tw-text-error-default tw-text-[16px] tw-underline tw-mt-[44px] md:tw-mt-[99px] xl:tw-mt-[39px]">
  84. {{$t('userProfile.deleteAccount')}}
  85. </button>
  86. </div>
  87. </div>
  88. <Transition name="bounce">
  89. <unLinkModal></unLinkModal>
  90. </Transition>
  91. <Transition name="bounce">
  92. <deleteAccountModal :userData="userData"></deleteAccountModal>
  93. </Transition>
  94. <loading :isLoading="isPageLoading"></loading>
  95. </div>
  96. </template>
  97. <script>
  98. import Setting from "../../components/user/Setting.vue";
  99. import SettingDialog from "../../components/user/settingDialog.vue";
  100. import BookingList from "../../components/user/bookingList.vue";
  101. import TwoDots from "@/components/TwoDots";
  102. import userSidebar from "@/components/user/userSidebar.vue";
  103. import unLinkModal from "@/components/newComponent/modal/unLinkModal.vue";
  104. import deleteAccountModal from "@/components/newComponent/modal/deleteAccountModal.vue";
  105. import loading from "@/components/newComponent/loading/loading.vue";
  106. export default {
  107. name: "setting",
  108. layout: "profile",
  109. components: {
  110. Setting,
  111. SettingDialog,
  112. BookingList,
  113. TwoDots,
  114. userSidebar,
  115. unLinkModal,
  116. deleteAccountModal,
  117. loading
  118. },
  119. data() {
  120. return {
  121. google: {},
  122. facebook: {},
  123. deleteDialogActive: false,
  124. valid: false,
  125. showPass: false,
  126. showConfirmPass: false,
  127. userPass: {
  128. user_old_pass: "",
  129. user_new_pass: "",
  130. },
  131. isNewPassValid: true,
  132. isOldPassValid: true,
  133. firstName: "",
  134. lastName: "",
  135. userData: {},
  136. SSOShow: 0,
  137. confirmPass: "",
  138. deleteAccountImg: require("~/assets/img/deleteAccount.png"),
  139. rules: {
  140. require: (value) => !!value || this.$t("Required."),
  141. email: (v) =>
  142. /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/.test(
  143. v
  144. ) || this.$t("Invalid email"),
  145. checkPassword: (v) =>
  146. (/(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])/.test(v) &&
  147. v.length >= 8 &&
  148. v.length <= 20) ||
  149. this.$t(
  150. "Passwords must be 8-20 characters with at least 1 number, 1 lower case letter and 1 upper case letter"
  151. ),
  152. checkConfirmPassword: (v) =>
  153. this.confirmPass === this.userPass.user_new_pass ||
  154. this.$t("Your password and confirmation password do not match"),
  155. },
  156. isPageLoading: false
  157. };
  158. },
  159. created() {
  160. this.isPageLoading = true;
  161. this.fetchUserData();
  162. if (process.browser) {
  163. window.addEventListener("resize", this.handleResize);
  164. }
  165. this.$nextTick(()=>{
  166. this.isPageLoading = false;
  167. });
  168. },
  169. mounted() {
  170. this.$nextTick(() => {
  171. window.addEventListener("resize", this.onResize);
  172. });
  173. },
  174. destroyed() {
  175. if (process.browser) {
  176. window.removeEventListener("resize", this.handleResize);
  177. }
  178. },
  179. computed: {
  180. windowWidth() {
  181. if (process.client) {
  182. this.width = window.innerWidth;
  183. }
  184. return this.width;
  185. },
  186. },
  187. methods: {
  188. handleResize() {
  189. if (process.browser) {
  190. this.width = window.innerWidth;
  191. }
  192. },
  193. //Get Member Info
  194. fetchUserData() {
  195. this.$axios
  196. .get(
  197. `/trending/api/Members/Info`
  198. )
  199. .then((response) => {
  200. //console.log(JSON.stringify(response));
  201. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  202. let data = response.data.DATA.rel
  203. if(data){
  204. this.userData = data;
  205. this.firstName = this.userData.FirstName;
  206. this.lastName = this.userData.LastName;
  207. }
  208. }
  209. })
  210. .catch((error) => {
  211. console.log(error);
  212. });
  213. },
  214. resetPassword() {
  215. if (
  216. this.isNewPassValid && this.isOldPassValid &&
  217. this.userPass.user_new_pass !== this.userPass.user_old_pass &&
  218. this.userPass.user_new_pass == this.confirmPass
  219. ) {
  220. this.$axios
  221. .post(
  222. `/trending/api/Members/ResetNewPassword/?Password=${this.userPass.user_new_pass}`
  223. )
  224. .then((response) => {
  225. //(JSON.stringify(response));
  226. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  227. let data = response.data.DATA.rel
  228. if(data){
  229. this.$auth.$storage.removeUniversal("userPicture");
  230. this.$auth.$storage.removeUniversal("userLastName");
  231. this.$auth.$storage.removeUniversal("userAccount");
  232. this.$auth.$storage.removeUniversal("userPassword");
  233. this.$notify({
  234. type: "success",
  235. title: "Awesome!",
  236. text: "Your password has been updated successfully.",
  237. });
  238. setTimeout(() => {
  239. this.$auth.logout();
  240. this.$router.push(this.localePath("/user"));
  241. }, 4000)
  242. }
  243. }
  244. })
  245. .catch((error) => {
  246. console.log(error);
  247. });
  248. }
  249. },
  250. cancel(){
  251. this.userPass.user_old_pass = "",
  252. this.userPass.user_new_pass = "",
  253. this.confirmPass = ""
  254. },
  255. checkOldPassword(v) {
  256. const pass = v.target.value;
  257. this.isOldPassValid =
  258. /(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])/.test(pass) &&
  259. pass.length >= 8 &&
  260. pass.length <= 20;
  261. },
  262. checkPassword(v) {
  263. const pass = v.target.value;
  264. this.isNewPassValid =
  265. /(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])/.test(pass) &&
  266. pass.length >= 8 &&
  267. pass.length <= 20;
  268. },
  269. openDeleteModal() {
  270. this.$modal.show('deleteAccountModal');
  271. }
  272. },
  273. };
  274. </script>
  275. <style scoped lang="scss">
  276. :deep(.v-text-field.v-text-field--enclosed .v-text-field__details) {
  277. padding: 0;
  278. margin: 0;
  279. }
  280. :deep(.v-messages__message) {
  281. font-size: 14px;
  282. }
  283. .v-text-field--outlined::v-deep {
  284. fieldset {
  285. border-color: #e5e5e5;
  286. }
  287. }
  288. .bounce-enter-active {
  289. animation: bounce-in 0.3s ease-out;
  290. }
  291. .bounce-leave-active {
  292. animation: bounce-in 0.3s cubic-bezier(1, 0.5, 0.8, 1) reverse;
  293. }
  294. @keyframes bounce-in {
  295. 0% {
  296. opacity: 0;
  297. transform: translateY(-10px);
  298. }
  299. 50% {
  300. opacity: 0.5;
  301. transform: translateY(-5px);
  302. }
  303. 100% {
  304. opacity: 1;
  305. transform: translateY(0);
  306. }
  307. }
  308. </style>