import { FormEvent, useState } from 'react' import { api } from './api' export default function Login({ onLogin }: { onLogin: () => void }) { const [pw, setPw] = useState('') const [err, setErr] = useState('') const [busy, setBusy] = useState(false) async function submit(e: FormEvent) { e.preventDefault() setBusy(true); setErr('') try { await api.login(pw); onLogin() } catch (e) { setErr(e instanceof Error ? e.message : 'login failed') } finally { setBusy(false) } } return (

Ham Lab

setPw(e.target.value)} /> {err &&
{err}
}
) }