import { useState } from "react"; import { api } from "../lib/api"; import type { AppConfig } from "../types"; export default function Login({ config, onSignedIn }: { config: AppConfig | null; onSignedIn: () => void; }) { 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 api.post("/api/auth/login", { email, password }); onSignedIn(); } catch (err) { setError(err instanceof Error ? err.message : "Sign-in failed"); } finally { setBusy(false); } }; return (