From a8408ce3e2051f0fafe3a20b4b8073a48a91bbe5 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Wed, 20 Jul 2022 08:40:55 +0200 Subject: [PATCH] refactor(gui-v2): replace v-form with a-form on forgot-password page --- packages/nc-gui-v2/pages/forgot-password.vue | 65 +++++++++++--------- packages/nc-gui-v2/pages/signin.vue | 6 +- packages/nc-gui-v2/pages/signup.vue | 6 +- 3 files changed, 43 insertions(+), 34 deletions(-) diff --git a/packages/nc-gui-v2/pages/forgot-password.vue b/packages/nc-gui-v2/pages/forgot-password.vue index 00a32ecb03..57bb46b7f2 100644 --- a/packages/nc-gui-v2/pages/forgot-password.vue +++ b/packages/nc-gui-v2/pages/forgot-password.vue @@ -20,7 +20,7 @@ definePageMeta({ let error = $ref(null) let success = $ref(false) -const valid = ref() +const valid = $ref() const formValidator = ref() @@ -31,13 +31,23 @@ const form = reactive({ const formRules = { email: [ // E-mail is required - (v: string) => !!v || t('msg.error.signUpRules.emailReqd'), + { required: true, message: t('msg.error.signUpRules.emailReqd') }, // E-mail must be valid format - (v: string) => isEmail(v) || t('msg.error.signUpRules.emailInvalid'), + { + validator: (_: unknown, v: string) => { + return new Promise((resolve, reject) => { + if (isEmail(v)) return resolve(true) + reject(new Error(t('msg.error.signUpRules.emailInvalid'))) + }) + }, + message: t('msg.error.signUpRules.emailInvalid'), + }, ], } const resetPassword = async () => { + if (!valid) return + error = null try { await $api.auth.passwordForgot(form) @@ -57,10 +67,13 @@ const resetError = () => { + + diff --git a/packages/nc-gui-v2/pages/signin.vue b/packages/nc-gui-v2/pages/signin.vue index 26002f7745..d999dbce60 100644 --- a/packages/nc-gui-v2/pages/signin.vue +++ b/packages/nc-gui-v2/pages/signin.vue @@ -148,9 +148,9 @@ const resetError = () => { @apply dark:!text-white; } } -} -.submit { - @apply ml-1 bordered border-gray-300 rounded-lg p-4 bg-gray-100/50 text-white bg-primary hover:bg-primary/75 dark:(!bg-secondary/75 hover:!bg-secondary/50); + .submit { + @apply ml-1 bordered border-gray-300 rounded-lg p-4 bg-gray-100/50 text-white bg-primary hover:bg-primary/75 dark:(!bg-secondary/75 hover:!bg-secondary/50); + } } diff --git a/packages/nc-gui-v2/pages/signup.vue b/packages/nc-gui-v2/pages/signup.vue index 4fbf660fa8..f80c72ade9 100644 --- a/packages/nc-gui-v2/pages/signup.vue +++ b/packages/nc-gui-v2/pages/signup.vue @@ -159,9 +159,9 @@ const resetError = () => { @apply dark:!text-white; } } -} -.submit { - @apply ml-1 bordered border-gray-300 rounded-lg p-4 bg-gray-100/50 text-white bg-primary hover:bg-primary/75 dark:(!bg-secondary/75 hover:!bg-secondary/50); + .submit { + @apply ml-1 bordered border-gray-300 rounded-lg p-4 bg-gray-100/50 text-white bg-primary hover:bg-primary/75 dark:(!bg-secondary/75 hover:!bg-secondary/50); + } }