Signup flow

This commit is contained in:
2023-07-20 12:33:00 +01:00
parent a1605e31d5
commit c74bbae5c7
24 changed files with 389 additions and 77 deletions

20
src/hooks/copy.tsx Normal file
View File

@ -0,0 +1,20 @@
import { useState } from "react";
export const useCopy = (timeout = 2000) => {
const [error, setError] = useState(false);
const [copied, setCopied] = useState(false);
const copy = async (text: string) => {
try {
await navigator.clipboard.writeText(text);
setCopied(true);
setError(false);
} catch (error) {
setError(true);
}
setTimeout(() => setCopied(false), timeout);
};
return { error, copied, copy };
};

View File

@ -1,9 +1,17 @@
import { Login } from "index";
import { getPublisher } from "login";
import { useSyncExternalStore } from "react";
export function useLogin() {
return useSyncExternalStore(
const session = useSyncExternalStore(
(c) => Login.hook(c),
() => Login.snapshot()
);
if (!session) return;
return {
...session,
publisher: () => {
return getPublisher(session);
}
}
}