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 (

{config?.app_name ?? "CX Triage"}

{config?.oidc_enabled && ( <> Sign in with SSO {config.local_login &&
or use a local account
} )} {config?.local_login !== false && (
setEmail(e.target.value)} autoComplete="username" />
setPassword(e.target.value)} autoComplete="current-password" />
{error &&
{error}
}
)}
); }