updated UI, minor fixes
This commit is contained in:
parent
b5280b70a1
commit
755c56ee8a
9 changed files with 175 additions and 98 deletions
|
|
@ -2,14 +2,17 @@ import { Heading, Input, Stack } from '@chakra-ui/react';
|
|||
import { Button } from '@client/components/ui/button';
|
||||
import { Field } from '@client/components/ui/field';
|
||||
import { valibotResolver } from '@hookform/resolvers/valibot';
|
||||
import { createFileRoute, useNavigate } from '@tanstack/react-router';
|
||||
import { createFileRoute, redirect } from '@tanstack/react-router';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import * as v from 'valibot';
|
||||
import { PasswordInput } from '../components/ui/password-input';
|
||||
import { useAuth } from '../hooks/auth';
|
||||
|
||||
export const Route = createFileRoute('/login')({
|
||||
component: LoginComponent
|
||||
component: LoginComponent,
|
||||
beforeLoad: ({ context }) => {
|
||||
if (context.isAuthenticated) throw redirect({ to: '/' });
|
||||
}
|
||||
});
|
||||
|
||||
function LoginComponent() {
|
||||
|
|
@ -27,8 +30,6 @@ interface FormValues {
|
|||
}
|
||||
|
||||
function LoginForm() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const schema = v.pipe(
|
||||
v.object({
|
||||
email: v.pipe(v.string(), v.nonEmpty('Email is required'), v.email('Invalid email')),
|
||||
|
|
@ -51,7 +52,7 @@ function LoginForm() {
|
|||
email: values.email,
|
||||
password: values.password
|
||||
});
|
||||
if (session != null) navigate({ to: '/' });
|
||||
if (session != null) window.history.back();
|
||||
})}
|
||||
>
|
||||
<Stack>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue