Files
yt2mp3/app/pages/login.vue
2026-01-14 12:36:32 +00:00

72 lines
1.6 KiB
Vue

<script setup lang="ts">
import * as z from 'zod'
import type { FormSubmitEvent, AuthFormField } from '@nuxt/ui'
const toast = useToast()
const wrong_login = ref(false)
const fields: AuthFormField[] = [{
name: 'email',
type: 'email',
label: 'Email',
placeholder: 'Enter your email',
required: true
}, {
name: 'password',
label: 'Password',
type: 'password',
placeholder: 'Enter your password',
required: true
} , {
name: 'remember',
label: 'Remember me',
type: 'checkbox'
}]
const schema = z.object({
email: z.email('Invalid email'),
password: z.string('Password is required').min(8, 'Must be at least 8 characters')
})
type Schema = z.output<typeof schema>
function onSubmit(payload: FormSubmitEvent<Schema>) {
console.log('Submitted', payload)
}
</script>
<template>
<div class="flex flex-col items-center justify-center gap-4 p-4 mt-7">
<UPageCard class="w-full max-w-md dark:bg-zinc-950 rounded-3xl">
<UAuthForm
:schema="schema"
title="Login"
description="Enter your credentials to access your account."
icon="i-lucide-user"
:fields="fields"
:submit="{
label: 'Login',
class: 'rounded-full',
variant: 'soft'
}"
>
<template #validation v-if="wrong_login">
<UAlert color="error"
icon="lucide:circle-x"
variant="soft"
:ui="{ icon: 'self-center' }"
title="Incorrect Login"
description="Either your e-mail or your password are wrong."/>
</template>
</UAuthForm>
</UPageCard>
</div>
</template>