Signup flow
This commit is contained in:
20
src/hooks/copy.tsx
Normal file
20
src/hooks/copy.tsx
Normal 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 };
|
||||
};
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user