Better form control and profile page

This commit is contained in:
2026-04-04 23:11:51 -05:00
parent 33b47d7ffb
commit 163ce564e5
6 changed files with 319 additions and 17 deletions

View File

@@ -12,6 +12,7 @@ import {
DialogFooter,
} from '../ui/dialog';
import { signUp, sendVerificationEmail } from '../../lib/auth-client';
import { validateEmail } from '../../lib/validators';
import { useEffect } from 'react';
const logo = '/logo.png';
@@ -48,6 +49,16 @@ export function SignUpForm({ onLogin }: Props) {
async function handleSubmit(e: React.FormEvent) {
e.preventDefault();
setError('');
const trimmedName = name.trim();
const trimmedEmail = email.trim();
if (trimmedName.length < 2) {
setError('Please enter your full name.');
return;
}
if (!validateEmail(trimmedEmail)) {
setError('Please enter a valid email address.');
return;
}
if (password.length < 8) {
setError('Password must be at least 8 characters');
return;
@@ -58,8 +69,8 @@ export function SignUpForm({ onLogin }: Props) {
}
setLoading(true);
const res = await signUp.email({
name,
email,
name: trimmedName,
email: trimmedEmail,
password,
callbackURL: window.location.origin,
});