Browse Source

refactor(gui-v2): replace v-form with a-form on forgot-password page

pull/2744/head
braks 2 years ago
parent
commit
a8408ce3e2
  1. 65
      packages/nc-gui-v2/pages/forgot-password.vue
  2. 6
      packages/nc-gui-v2/pages/signin.vue
  3. 6
      packages/nc-gui-v2/pages/signup.vue

65
packages/nc-gui-v2/pages/forgot-password.vue

@ -20,7 +20,7 @@ definePageMeta({
let error = $ref<string | null>(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 = () => {
<template>
<NuxtLayout>
<v-form
<a-form
ref="formValidator"
v-model="valid"
class="h-full min-h-[600px] flex justify-center items-center"
layout="vertical"
:model="form"
class="forgot-password h-full min-h-[600px] flex justify-center items-center"
@finish="valid = true"
@finish-failed="valid = false"
@submit.prevent="resetPassword"
>
<div class="h-full w-full flex flex-col flex-wrap justify-center items-center">
@ -91,29 +104,12 @@ const resetError = () => {
</div>
</Transition>
<v-text-field
id="email"
v-model="form.email"
class="bg-white dark:!bg-gray-900"
:rules="formRules.email"
:label="$t('labels.email')"
:placeholder="$t('labels.email')"
:persistent-placeholder="true"
type="text"
@focus="resetError"
/>
<a-form-item :label="$t('labels.email')" name="email" :rules="formRules.email">
<a-input v-model:value="form.email" size="large" :placeholder="$t('labels.email')" @focus="resetError" />
</a-form-item>
<div class="self-center flex flex-wrap gap-4 items-center mt-4 md:mx-8 md:justify-between justify-center w-full">
<button
:disabled="!valid"
:class="[
!valid
? '!opacity-50 !cursor-default'
: 'text-white bg-primary hover:(text-primary !bg-primary/75) dark:(!bg-secondary/75 hover:!bg-secondary/50)',
]"
class="ml-1 border-1 border-solid border-gray-300 color-transition rounded-lg p-4 bg-gray-100/50"
type="submit"
>
<button class="submit" type="submit">
<span class="flex items-center gap-2"><MdiLogin /> {{ $t('activity.sendEmail') }}</span>
</button>
<div class="text-end prose-sm">
@ -123,6 +119,19 @@ const resetError = () => {
</div>
</div>
</div>
</v-form>
</a-form>
</NuxtLayout>
</template>
<style lang="scss">
.forgot-password {
.ant-input-affix-wrapper,
.ant-input {
@apply dark:(bg-gray-700 !text-white) !appearance-none my-1 border-1 border-solid border-primary/50 rounded;
}
.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);
}
}
</style>

6
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);
}
}
</style>

6
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);
}
}
</style>

Loading…
Cancel
Save