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.

309 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
  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. </div>
  95. </template>
  96. <script>
  97. import Setting from "../../components/user/Setting.vue";
  98. import SettingDialog from "../../components/user/settingDialog.vue";
  99. import BookingList from "../../components/user/bookingList.vue";
  100. import TwoDots from "@/components/TwoDots";
  101. import userSidebar from "@/components/user/userSidebar.vue";
  102. import unLinkModal from "@/components/newComponent/modal/unLinkModal.vue";
  103. import deleteAccountModal from "@/components/newComponent/modal/deleteAccountModal.vue";
  104. export default {
  105. name: "setting",
  106. layout: "profile",
  107. components: {
  108. Setting,
  109. SettingDialog,
  110. BookingList,
  111. TwoDots,
  112. userSidebar,
  113. unLinkModal,
  114. deleteAccountModal,
  115. },
  116. data() {
  117. return {
  118. google: {},
  119. facebook: {},
  120. deleteDialogActive: false,
  121. valid: false,
  122. showPass: false,
  123. showConfirmPass: false,
  124. userPass: {
  125. user_old_pass: "",
  126. user_new_pass: "",
  127. },
  128. isNewPassValid: true,
  129. isOldPassValid: true,
  130. firstName: "",
  131. lastName: "",
  132. userData: {},
  133. SSOShow: 0,
  134. confirmPass: "",
  135. deleteAccountImg: require("~/assets/img/deleteAccount.png"),
  136. rules: {
  137. require: (value) => !!value || this.$t("Required."),
  138. email: (v) =>
  139. /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/.test(
  140. v
  141. ) || this.$t("Invalid email"),
  142. checkPassword: (v) =>
  143. (/(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])/.test(v) &&
  144. v.length >= 8 &&
  145. v.length <= 20) ||
  146. this.$t(
  147. "Passwords must be 8-20 characters with at least 1 number, 1 lower case letter and 1 upper case letter"
  148. ),
  149. checkConfirmPassword: (v) =>
  150. this.confirmPass === this.userPass.user_new_pass ||
  151. this.$t("Your password and confirmation password do not match"),
  152. },
  153. };
  154. },
  155. created() {
  156. this.fetchUserData();
  157. if (process.browser) {
  158. window.addEventListener("resize", this.handleResize);
  159. }
  160. },
  161. mounted() {
  162. this.$nextTick(() => {
  163. window.addEventListener("resize", this.onResize);
  164. });
  165. },
  166. destroyed() {
  167. if (process.browser) {
  168. window.removeEventListener("resize", this.handleResize);
  169. }
  170. },
  171. computed: {
  172. windowWidth() {
  173. if (process.client) {
  174. this.width = window.innerWidth;
  175. }
  176. return this.width;
  177. },
  178. },
  179. methods: {
  180. handleResize() {
  181. if (process.browser) {
  182. this.width = window.innerWidth;
  183. }
  184. },
  185. //Get Member Info
  186. fetchUserData() {
  187. this.$axios
  188. .get(
  189. `/trending/api/Members/Info`
  190. )
  191. .then((response) => {
  192. //console.log(JSON.stringify(response));
  193. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  194. let data = response.data.DATA.rel
  195. if(data){
  196. this.userData = data;
  197. this.firstName = this.userData.FirstName;
  198. this.lastName = this.userData.LastName;
  199. }
  200. }
  201. })
  202. .catch((error) => {
  203. console.log(error);
  204. });
  205. },
  206. resetPassword() {
  207. if (
  208. this.isNewPassValid && this.isOldPassValid &&
  209. this.userPass.user_new_pass !== this.userPass.user_old_pass &&
  210. this.userPass.user_new_pass == this.confirmPass
  211. ) {
  212. this.$axios
  213. .post(
  214. `/trending/api/Members/ResetNewPassword/?Password=${this.userPass.user_new_pass}`
  215. )
  216. .then((response) => {
  217. //(JSON.stringify(response));
  218. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  219. let data = response.data.DATA.rel
  220. if(data){
  221. this.$auth.$storage.removeUniversal("userPicture");
  222. this.$auth.$storage.removeUniversal("userLastName");
  223. this.$auth.$storage.removeUniversal("userAccount");
  224. this.$auth.$storage.removeUniversal("userPassword");
  225. this.$notify({
  226. type: "success",
  227. title: "Awesome!",
  228. text: "Your password has been updated successfully.",
  229. });
  230. setTimeout(() => {
  231. this.$auth.logout();
  232. this.$router.push(this.localePath("/user"));
  233. }, 4000)
  234. }
  235. }
  236. })
  237. .catch((error) => {
  238. console.log(error);
  239. });
  240. }
  241. },
  242. cancel(){
  243. this.userPass.user_old_pass = "",
  244. this.userPass.user_new_pass = "",
  245. this.confirmPass = ""
  246. },
  247. checkOldPassword(v) {
  248. const pass = v.target.value;
  249. this.isOldPassValid =
  250. /(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])/.test(pass) &&
  251. pass.length >= 8 &&
  252. pass.length <= 20;
  253. },
  254. checkPassword(v) {
  255. const pass = v.target.value;
  256. this.isNewPassValid =
  257. /(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])/.test(pass) &&
  258. pass.length >= 8 &&
  259. pass.length <= 20;
  260. },
  261. openDeleteModal() {
  262. this.$modal.show('deleteAccountModal');
  263. }
  264. },
  265. };
  266. </script>
  267. <style scoped lang="scss">
  268. :deep(.v-text-field.v-text-field--enclosed .v-text-field__details) {
  269. padding: 0;
  270. margin: 0;
  271. }
  272. :deep(.v-messages__message) {
  273. font-size: 14px;
  274. }
  275. .v-text-field--outlined::v-deep {
  276. fieldset {
  277. border-color: #e5e5e5;
  278. }
  279. }
  280. .bounce-enter-active {
  281. animation: bounce-in 0.3s ease-out;
  282. }
  283. .bounce-leave-active {
  284. animation: bounce-in 0.3s cubic-bezier(1, 0.5, 0.8, 1) reverse;
  285. }
  286. @keyframes bounce-in {
  287. 0% {
  288. opacity: 0;
  289. transform: translateY(-10px);
  290. }
  291. 50% {
  292. opacity: 0.5;
  293. transform: translateY(-5px);
  294. }
  295. 100% {
  296. opacity: 1;
  297. transform: translateY(0);
  298. }
  299. }
  300. </style>