/** * Register Page – New user registration */ import { useState, type FormEvent } from 'react'; import { useAuth } from '../contexts/AuthContext'; interface RegisterProps { onSwitchToLogin: () => void; } export function Register({ onSwitchToLogin }: RegisterProps) { const { register, loading, error, clearError } = useAuth(); const [email, setEmail] = useState(''); const [name, setName] = useState(''); const [password, setPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [localError, setLocalError] = useState(null); const handleSubmit = async (e: FormEvent) => { e.preventDefault(); setLocalError(null); if (password !== confirmPassword) { setLocalError('Passwörter stimmen nicht überein'); return; } if (password.length < 6) { setLocalError('Passwort muss mindestens 6 Zeichen lang sein'); return; } try { await register(email, password, name); } catch { // error is set in context } }; const displayError = localError || error; return (

Web CAD

Registrieren

{displayError && (
{ clearError(); setLocalError(null); }}> {displayError}
)}
setName(e.target.value)} required autoFocus placeholder="Ihr Name" />
setEmail(e.target.value)} required placeholder="name@example.com" />
setPassword(e.target.value)} required placeholder="min. 6 Zeichen" />
setConfirmPassword(e.target.value)} required placeholder="••••••••" />

Bereits ein Konto?{' '}

); }