import { useState } from 'react'; import { Link } from 'react-router-dom'; import { api, AuthResponse, User } from '../lib/api'; interface SignUpProps { onSuccess: (user: User, token: string) => void; } export default function SignUp({ onSuccess }: SignUpProps) { const [email, setEmail] = useState(''); const [displayName, setDisplayName] = useState(''); const [password, setPassword] = useState(''); const [passwordVerify, setPasswordVerify] = useState(''); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); if (password !== passwordVerify) { setError('Passwords do not match'); return; } setLoading(true); try { const response = await api.post('/auth/sign-up', { email, password, displayName, }); onSuccess(response.user, response.token); } catch (err) { setError(err instanceof Error ? err.message : 'Sign up failed'); } finally { setLoading(false); } }; return (

Create Account

{error && (
{error}
)}
setEmail(e.target.value)} className="w-full px-4 py-2 bg-bg-tertiary border border-border-default rounded-lg text-text-primary focus:outline-none focus:border-brand" required />
setDisplayName(e.target.value)} className="w-full px-4 py-2 bg-bg-tertiary border border-border-default rounded-lg text-text-primary focus:outline-none focus:border-brand" required />
setPassword(e.target.value)} className="w-full px-4 py-2 bg-bg-tertiary border border-border-default rounded-lg text-text-primary focus:outline-none focus:border-brand" required />
setPasswordVerify(e.target.value)} className="w-full px-4 py-2 bg-bg-tertiary border border-border-default rounded-lg text-text-primary focus:outline-none focus:border-brand" required />
Cancel
); }