import { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import { api } from "../api/client"; import { AppShell, Notice, TopBar } from "../components/AppShell"; import { Icon } from "../components/Icon"; import { ru } from "../content/ru"; import { useSession } from "../session/SessionContext"; // Anonymous means no identifying data, with the same screening and care path. export function AnonymousSignIn() { const t = ru.anonymous; const navigate = useNavigate(); const { signIn } = useSession(); const [busy, setBusy] = useState(false); const [error, setError] = useState(false); const [screening, setScreening] = useState(null); useEffect(() => { let alive = true; api.patientCapabilities() .then((v) => { if (alive) setScreening(v.primary_screening); }) .catch(() => { if (alive) setError(true); }); return () => { alive = false; }; }, []); const start = async () => { setBusy(true); setError(false); try { // No self-selected diagnosis: the common intake determines the follow-up modules. signIn(await api.signInAnonymous()); navigate("/flow", { replace: true }); } catch { setError(true); setBusy(false); } }; return (
navigate("/")} />

{t.title}

{t.lead}

{t.note} {screening === false && {t.unavailable}} {error && {ru.common.networkError}}
); }