import { useState } from "react"; import { login } from "../api"; export function Login({ onLoggedIn }: { onLoggedIn: () => void }) { const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(null); const [submitting, setSubmitting] = useState(false); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setError(null); setSubmitting(true); try { await login(username, password); onLoggedIn(); } catch (err) { setError(err instanceof Error ? err.message : "Login failed"); } finally { setSubmitting(false); } } return (

Homelab Monitor

setUsername(e.target.value)} autoFocus /> setPassword(e.target.value)} /> {error &&

{error}

}
); }