feat: rewrite auth (#364)
* feat: wip rewrite auth * feat: restructure folders and fix stories and tests * feat: remove auth provider and fix tests
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { cookieStorage } from '@/utils/cookie-storage';
|
||||
|
||||
export function useIsLogged(): boolean {
|
||||
const [value, setValue] = useState<string | undefined>(
|
||||
cookieStorage.getItem('accessToken'),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const updateValue = (newValue: string | undefined) => setValue(newValue);
|
||||
|
||||
cookieStorage.addEventListener('accessToken', updateValue);
|
||||
|
||||
return () => {
|
||||
cookieStorage.removeEventListener('accessToken', updateValue);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return !!value;
|
||||
}
|
||||
Reference in New Issue
Block a user