import { createSignal, Show } from "solid-js"; import "./oauth-config"; import { useOAuthScopeFlow } from "./scope-flow"; import { ScopeSelector } from "./scope-selector"; interface LoginProps { onCancel?: () => void; } export const Login = (props: LoginProps) => { const [notice, setNotice] = createSignal(""); const [loginInput, setLoginInput] = createSignal(""); const scopeFlow = useOAuthScopeFlow({ onError: (e) => setNotice(`${e}`), onRedirecting: () => { setNotice(`Contacting your data server...`); setTimeout(() => setNotice(`Redirecting...`), 0); }, }); const initiateLogin = (handle: string) => { setNotice(""); scopeFlow.initiate(handle); }; const handleCancel = () => { scopeFlow.cancel(); setLoginInput(""); setNotice(""); props.onCancel?.(); }; return (
Add account
e.preventDefault()}> setTimeout(() => el.focus())} aria-label="Your AT Protocol handle" class="dark:bg-dark-100 rounded-lg bg-white px-2.5 py-2 outline-1 outline-neutral-200 select-none focus:outline-neutral-400 dark:outline-neutral-600 dark:focus:outline-neutral-400" onInput={(e) => setLoginInput(e.currentTarget.value)} />
{notice()}
); };