import { useEffect, useState } from 'react'; import { Link as RouterLink } from 'react-router'; import { getMe, signInUrl, signOut, unlink, type AccountMe } from '../lib/account'; // The signed-in account: which DorkNet account and provider email are // linked, plus sign out and unlink. export function Account() { const [me, setMe] = useState(null); const [err, setErr] = useState(null); const [busy, setBusy] = useState(false); useEffect(() => { getMe(true).then(setMe).catch((e) => setErr((e as Error).message)); }, []); const run = async (action: () => Promise) => { setBusy(true); try { await action(); window.location.assign('/'); } catch (e) { setErr((e as Error).message); setBusy(false); } }; if (err) return
{err}
; if (!me) return

Loading…

; if (!me.signedIn || !me.player) { return (

Account

You're not signed in.

{me.signInAvailable ? Sign in with {me.provider} :

Sign-in isn't set up on this server.

}
); } return (

Account

DorkNet account {me.player.username}
Signed in with {me.provider} {me.player.email || '—'}
); }