import { useState } from 'react'; import { Link, useNavigate } from 'react-router-dom'; import { useAuth } from '../auth/AuthContext'; import { Button, Card, Field, Input } from '../components/ui'; export function Login() { return ; } export function Signup() { return ; } function AuthForm({ mode }: { mode: 'login' | 'signup' }) { const { login, signup } = useAuth(); const nav = useNavigate(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [busy, setBusy] = useState(false); const submit = async (e: React.FormEvent) => { e.preventDefault(); setBusy(true); setError(''); try { await (mode === 'login' ? login(email, password) : signup(email, password)); nav('/'); } catch (err) { setError((err as Error).message); } finally { setBusy(false); } }; return (

Scoreboard Tools

{mode === 'login' ? 'Sign in to your dashboard' : 'Create an account'}

setEmail(e.target.value)} required /> setPassword(e.target.value)} required minLength={6} /> {error &&

{error}

}

{mode === 'login' ? ( <>No account? Sign up ) : ( <>Have an account? Sign in )}

); }