import type { FormEvent } from "react"; import { useState } from "react"; import { api, errorMessage } from "../api"; import { Alert } from "../components/ui"; import { useI18n } from "../i18n"; import { ThemeSwitch } from "../theme"; export function LoginPage({ onLogin }: { onLogin: (actor: string) => void }) { const { t } = useI18n(); const [secret, setSecret] = useState(""); const [error, setError] = useState(""); const [busy, setBusy] = useState(false); async function submit(event: FormEvent) { event.preventDefault(); setBusy(true); setError(""); try { const result = await api.login(secret); onLogin(result.actor); } catch (err) { setError(errorMessage(err)); } finally { setBusy(false); } } return (
OwpenGram OwpenGram {t("app.adminConsole")}
{t("app.localAccess")}

{t("login.heading")}

{t("login.body")}

{error && {error}}
); }