updated UI, minor fixes

This commit is contained in:
lnn0q 2025-04-20 18:10:34 +03:00
parent b5280b70a1
commit 755c56ee8a
9 changed files with 175 additions and 98 deletions

View file

@ -5,13 +5,16 @@ import { Field } from '@client/components/ui/field';
import { PasswordInput } from '@client/components/ui/password-input';
import { Session } from '@generated/types';
import { valibotResolver } from '@hookform/resolvers/valibot';
import { createFileRoute, useNavigate } from '@tanstack/react-router';
import { createFileRoute, redirect, useNavigate } from '@tanstack/react-router';
import { useForm } from 'react-hook-form';
import * as v from 'valibot';
import { useToastMutation } from '../hooks/useToastMutation';
export const Route = createFileRoute('/register')({
component: RegisterComponent
component: RegisterComponent,
beforeLoad: ({ context }) => {
if (context.isAuthenticated) throw redirect({ to: '/' });
}
});
function RegisterComponent() {
@ -43,8 +46,11 @@ function SignUpForm() {
username: v.pipe(v.string(), v.nonEmpty('Username is required')),
password: v.pipe(
v.string(),
v.nonEmpty('Password is required'),
v.minLength(8, 'Needs to be at least 8 characters')
v.minLength(8, 'Your password is too short.'),
v.maxLength(45, 'Your password is too long.'),
v.regex(/[a-z]/, 'Your password must contain a lowercase letter.'),
v.regex(/[A-Z]/, 'Your password must contain a uppercase letter.'),
v.regex(/[0-9]/, 'Your password must contain a number.')
),
confirm_password: v.pipe(v.string(), v.nonEmpty('Confirm your password'))
}),