feat: account

This commit is contained in:
ner committed 2024-10-18 18:56:34 +03:00
1 parent df0f7c943b
commit 043375f44a
17 files changed
+305 -131

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
import { atom, useAtomValue, useSetAtom } from 'jotai';
import Cookies from 'js-cookie';
import { useCallback } from 'react';
const sessionAtom = atom<string | null>(Cookies.get('session') as string);
export const useSession = () => useAtomValue(sessionAtom);
export const useSetSession = () => {
const setSession = useSetAtom(sessionAtom);
return useCallback(
(session: string | null) => {
typeof session === 'string' ? Cookies.set('session', session) : Cookies.remove('session');
setSession(session);
},
[setSession]
);
};