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.

294 lines
11 KiB

2 years ago
  1. <template>
  2. <div class="tw-bg-white md:tw-rounded-[24px] md:tw-mt-[30px] md:tw-pt-[60px] md:tw-pb-[150px] md:tw-px-[30px]">
  3. <v-spacer v-if="emailSignUp">
  4. <h1 class="tw-text-[40px] tw-font-bold tw-mb-[20px] md:tw-text-[24px] md:tw-mb-[14px]">{{ $t("Sign Up") }}</h1>
  5. <p class="tw-body-3 tw-text-neutral-400 tw-mb-[16px] md:tw-mb-[12px]">
  6. {{ $t("Welcome to ShowEasy!") }}
  7. </p>
  8. <p class="tw-body-3 tw-mb-[45px] md:tw-mb-[32px]">
  9. {{ $t("Already have an account?") }}
  10. <nuxt-link :to="localePath('/user')" class="primary--text text-decoration-none">{{ $t("Login") }}</nuxt-link>
  11. </p>
  12. <div class="tw-grid tw-grid-cols-1 tw-gap-[10px] md:tw-gap-[12px]">
  13. <button @click="googleLogin"
  14. class="tw-flex tw-justify-center tw-items-center tw-w-full tw-py-[8px] tw-rounded-[16px] tw-border tw-border-solid tw-text-black tw-border-neutrals-200"><img
  15. width="24px" height="24px" src="~/assets/img/g-normal.png" class="mr-5" />{{ $t("Sign up with Google")
  16. }}</button>
  17. <button @click="facebookLogin"
  18. class="tw-flex tw-justify-center tw-items-center tw-w-full tw-py-[8px] tw-rounded-[16px] tw-border tw-border-solid tw-text-black tw-border-neutrals-200"><img
  19. width="20px" height="20px" src="~/assets/img/f_logo_RGB-Blue_72.png" class="mr-5" />
  20. {{ $t("Sign up with Facebook") }}
  21. </button>
  22. <button @click="emailSignUp = !emailSignUp"
  23. class="tw-flex tw-justify-center tw-items-center tw-w-full tw-py-[8px] tw-rounded-[16px] tw-border tw-border-solid tw-text-black tw-border-neutrals-200">
  24. <unicon name="envelope" width="20px" height="20px"
  25. class="tw-flex tw-justify-center tw-items-center tw-mr-[20px]">
  26. </unicon>{{ $t("Sign up with Email") }}
  27. </button>
  28. </div>
  29. </v-spacer>
  30. <v-spacer v-if="!emailSignUp">
  31. <p class="title">{{ $t("Sign up with Email") }}</p>
  32. <p class="neutrals--text text--darken-3 text-size-14">
  33. {{ $t("Welcome to ShowEasy!") }}
  34. </p>
  35. <v-form v-model="valid">
  36. <v-text-field v-model="userData.first_name" background-color="neutrals darken-1"
  37. :label="this.$t('First Name') + '*'" placeholder="" filled rounded dense single-line :rules="[rules.require]">
  38. </v-text-field>
  39. <v-text-field v-model="userData.last_name" background-color="neutrals darken-1"
  40. :label="this.$t('Last Name') + '*'" placeholder="" filled rounded dense single-line :rules="[rules.require]">
  41. </v-text-field>
  42. <v-text-field v-model="userData.email" background-color="neutrals darken-1" :label="this.$t('Email') + '*'"
  43. filled rounded dense single-line :rules="[rules.email, rules.require]" validate-on-blur></v-text-field>
  44. <v-text-field v-model="userData.password" background-color="neutrals darken-1"
  45. :label="this.$t('Password') + '*'" :type="showPass ? 'text' : 'password'" placeholder="" filled rounded dense
  46. single-line :rules="[rules.checkPassword, rules.require]" :hint="
  47. this.$t(
  48. 'userProfile.passwordsHint'
  49. )
  50. " persistent-hint :append-icon="showPass ? 'mdi-eye' : 'mdi-eye-off'" @click:append="showPass = !showPass"
  51. validate-on-blur></v-text-field>
  52. <v-text-field v-model="confirmPasswordText" background-color="neutrals darken-1"
  53. :label="this.$t('Confirm Password') + '*'" :type="showConfirmPass ? 'text' : 'password'" placeholder="" filled
  54. rounded dense single-line :rules="[rules.checkConfirmPassword, rules.require]"
  55. :append-icon="showConfirmPass ? 'mdi-eye' : 'mdi-eye-off'" @click:append="showConfirmPass = !showConfirmPass"
  56. validate-on-blur></v-text-field>
  57. </v-form>
  58. <v-checkbox v-model="subscribe" class="mt-n2 ml-1"><template v-slot:label><span
  59. class="neutrals--text text--darken-4 text-size-14">{{
  60. $t("Subscribe to ShowEasy\’s newsletter")
  61. }}</span></template></v-checkbox>
  62. <div class="md:tw-flex md:tw-justify-center md:tw-items-center"> <button @click="userRegister"
  63. :disabled="!validFormat"
  64. :class="['tw-block tw-w-full tw-py-[10px] tw-rounded-[16px] tw-border tw-border-solid tw-body-3 tw-font-normal tw-transition-all tw-duration-200 tw-ease-in-out',valid?'tw-text-white tw-bg-primary-default tw-border-primary-default':'tw-text-base-disable tw-bg-neutral-100 tw-border-neutral-100']">
  65. {{ $t("Sign Up") }}
  66. </button></div>
  67. <v-dialog v-model="dialog" :width="$vuetify.breakpoint.smAndUp ? 423 : 294"
  68. @click:outside="$router.push(localePath('/user'))">
  69. <v-card class="pa-7" :height="$vuetify.breakpoint.smAndUp ? 249 : 290">
  70. <v-spacer class="d-flex align-center text-size-20 neutrals--text text--darken-5">
  71. {{ $t("Verify your email") }}
  72. <v-spacer></v-spacer>
  73. <v-btn @click="$router.push(localePath('/user'))" icon>
  74. <v-icon> mdi-close </v-icon>
  75. </v-btn>
  76. </v-spacer>
  77. <v-spacer class="text-size-16 my-7 neutrals--text text--darken-4">{{ $t("We've sent a verification email to")
  78. }}<br />
  79. <span class="primary--text">{{ userData.email }}</span>{{
  80. $t(". Please click the link within to activate your account.")
  81. }}
  82. </v-spacer>
  83. <v-btn @click="resendVerifyEmail" class="primary no-text-transform" width="153px" rounded
  84. :disabled="countdown > 0">
  85. {{ $t("Resend") }}
  86. <span v-if="countdown > 0">
  87. {{ `(${this.countdown})` }}
  88. </span>
  89. </v-btn>
  90. </v-card>
  91. </v-dialog>
  92. <v-dialog v-model="errorDialog" :width="$vuetify.breakpoint.smAndUp ? 423 : 294">
  93. <v-card class="pa-7 border-radius-16" :max-height="$vuetify.breakpoint.smAndUp ? 249 : 290">
  94. <v-spacer class="d-flex align-center text-size-20 neutrals--text text--darken-5">
  95. {{ $t("Error") }}
  96. <v-spacer></v-spacer>
  97. <v-btn @click="errorDialog = !errorDialog" icon>
  98. <v-icon> mdi-close </v-icon>
  99. </v-btn>
  100. </v-spacer>
  101. <v-spacer class="text-size-16 my-7 neutrals--text text--darken-4">
  102. {{ $t("Same email has been created already.") }}
  103. </v-spacer>
  104. <v-spacer class="d-flex justify-center">
  105. <v-btn class="border-radius-16" color="primary" @click="errorDialog = !errorDialog">{{ $t("ok") }}</v-btn>
  106. </v-spacer>
  107. </v-card>
  108. </v-dialog>
  109. <p align="center" class="neutrals--text text--darken-3 text-size-14 mt-7">
  110. {{ $t("By signing up,") }}<br />
  111. {{ $t("you agree to the") }}
  112. <nuxt-link :to="localePath('/termsandconditions')" target="_blank" class="text-decoration-none">
  113. {{ $t("Terms & Conditions") }}</nuxt-link>
  114. {{ $t("and") }}
  115. <nuxt-link :to="localePath('/privacypolicy')" target="_blank" class="text-decoration-none">
  116. {{ $t("Privacy Policy") }}</nuxt-link>
  117. </p>
  118. <p align="center" class="neutrals--text text--darken-5 text-size-14">
  119. {{ $t("Already have an account?") }}
  120. <nuxt-link :to="localePath('/user')" class="primary--text text-decoration-none">{{ $t("Login") }}</nuxt-link>
  121. </p>
  122. </v-spacer>
  123. <loading :isLoading="isPageLoading"></loading>
  124. </div>
  125. </template>
  126. <script>
  127. import loading from "@/components/newComponent/loading/loading.vue";
  128. export default {
  129. name: "SignUp",
  130. layout: "login",
  131. auth: false,
  132. components: {
  133. loading,
  134. },
  135. data() {
  136. return {
  137. valid: false,
  138. showPass: false,
  139. showConfirmPass: false,
  140. emailSignUp: true,
  141. subscribe: true,
  142. dialog: false,
  143. errorDialog: false,
  144. btnText: "Sign up",
  145. confirmPasswordText: "",
  146. countdown: 60,
  147. isPageLoading: false,
  148. rules: {
  149. require: (value) => !!value || this.$t("Required."),
  150. email: (v) =>
  151. /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/.test(
  152. v
  153. ) || this.$t("Invalid email"),
  154. checkPassword: (v) =>
  155. (/(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])/.test(v) &&
  156. v.length >= 8 &&
  157. v.length <= 20) ||
  158. this.$t(
  159. "Passwords must be 8-20 characters with at least 1 number, 1 lower case letter and 1 upper case letter"
  160. ),
  161. checkConfirmPassword: (v) =>
  162. this.confirmPasswordText === this.userData.password ||
  163. this.$t("Your password and confirmation password do not match"),
  164. },
  165. userData: {
  166. first_name: "",
  167. last_name: "",
  168. email: "",
  169. password: "",
  170. },
  171. };
  172. },
  173. methods: {
  174. userRegister() {
  175. const postUserData = { ...this.userData };
  176. if (this.valid && this.userData.password === this.confirmPasswordText) {
  177. this.isPageLoading = true;
  178. this.$axios
  179. .post(`/member/users?lang=${this.$i18n.locale}`, postUserData)
  180. .then((res) => {
  181. console.log(res);
  182. this.timer = setInterval(() => {
  183. if (this.countdown > 0) {
  184. this.countdown--;
  185. }
  186. if (this.countdown === 0) {
  187. clearInterval(this.timer);
  188. }
  189. }, 1000);
  190. this.isPageLoading = false;
  191. this.dialog = !this.dialog;
  192. })
  193. .catch((err) => {
  194. if (err.response.status === 401) {
  195. this.errorDialog = true;
  196. this.isPageLoading = false;
  197. }
  198. });
  199. }
  200. },
  201. resendVerifyEmail() {
  202. this.countdown = 60;
  203. this.$axios
  204. .get(
  205. `/member/users/resend/${this.userData.email}?lang=${this.$i18n.locale}`
  206. )
  207. .then((res) => {
  208. clearInterval(this.timer);
  209. this.timer = setInterval(() => {
  210. if (this.countdown > 0) {
  211. this.countdown--;
  212. }
  213. if (this.countdown === 0) {
  214. clearInterval(this.timer);
  215. }
  216. }, 1000);
  217. })
  218. .catch((err) => {
  219. console.log(err);
  220. });
  221. },
  222. async facebookLogin() {
  223. try {
  224. await this.$auth.loginWith("facebook");
  225. } catch (err) {
  226. console.log(err);
  227. }
  228. },
  229. async googleLogin() {
  230. try {
  231. await this.$auth.loginWith("google");
  232. } catch (err) {
  233. console.log(err);
  234. }
  235. },
  236. },
  237. computed: {
  238. validFormat() {
  239. if (this.valid && this.userData.password === this.confirmPasswordText) {
  240. return true;
  241. } else {
  242. return false;
  243. }
  244. },
  245. },
  246. beforeUnmount() {
  247. clearInterval(this.timer);
  248. },
  249. };
  250. </script>
  251. <style lang="scss" scoped>
  252. :deep(.v-text-field.v-text-field--enclosed .v-text-field__details) {
  253. padding: 0;
  254. margin: 0;
  255. }
  256. :deep(.v-messages__message) {
  257. font-size: 14px;
  258. }
  259. $border-style: 1px solid #e5e5e5;
  260. .title {
  261. font-weight: 700;
  262. font-size: 26px;
  263. line-height: 34px;
  264. letter-spacing: 0.02em;
  265. color: #232323;
  266. }
  267. :deep(.v-text-field.v-text-field--enclosed .v-text-field__details) {
  268. margin-bottom: 0;
  269. padding: 0;
  270. .v-messages {
  271. color: #9c9c9c;
  272. display: none;
  273. }
  274. .v-messages.error--text {
  275. display: block;
  276. margin-top: 4px;
  277. margin-bottom: 16px;
  278. }
  279. }
  280. .btn-border {
  281. border: $border-style;
  282. }
  283. </style>