import { useState } from 'react'; import { useNavigate, Link } from 'react-router-dom'; import { useAuthStore } from '../../store/authStore'; import { Blocks, Eye, EyeOff, Mail, User as UserIcon, Lock, Check } from 'lucide-react'; import GoogleButton from './GoogleButton'; export default function RegisterForm() { const [email, setEmail] = useState(''); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [showPassword, setShowPassword] = useState(false); const [passwordError, setPasswordError] = useState(''); const [formError, setFormError] = useState(''); const { register, loading, error: storeError, clearError } = useAuthStore(); const navigate = useNavigate(); const displayError = formError || storeError; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setPasswordError(''); setFormError(''); if (password !== confirmPassword) { setPasswordError('Passwords do not match'); return; } if (password.length < 8) { setPasswordError('Password must be at least 8 characters'); return; } try { await register(email, username, password); navigate('/dashboard'); } catch (err: any) { setFormError(err.message || 'Registration failed. Please try again.'); } }; return (
RealBlocks

Create your account

{(displayError || passwordError) && (
{passwordError || displayError}
)}
{ setUsername(e.target.value); clearError(); }} className="input pl-10" placeholder="coolcoder" required minLength={3} maxLength={30} pattern="^[a-zA-Z0-9_]+$" />
{ setEmail(e.target.value); clearError(); }} className="input pl-10" placeholder="you@example.com" required />
{ setPassword(e.target.value); clearError(); setPasswordError(''); }} className="input pl-10 pr-10" placeholder="••••••••" required minLength={8} />
= 8 ? 'text-green-400' : 'text-surface-400'}`}> 8+ chars Uppercase Number
setConfirmPassword(e.target.value)} className="input pl-10" placeholder="••••••••" required />
or continue with

Already have an account?{' '} Sign in

); }