This commit is contained in:
hamid
2026-06-16 01:32:43 +03:30
commit 69bbd28bb0
298 changed files with 24728 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
import { useCallback } from 'react';
import { sessionStorageGet, sessionStorageDelete } from '@/utils/sessionStorage';
import { useAppStore } from '../store';
/**
* Hook to detect is current user authenticated or not
* @returns {boolean} true if user is authenticated, false otherwise
*/
export function useIsAuthenticated() {
const [state] = useAppStore();
let result = state.isAuthenticated;
// TODO: AUTH: replace next line with access token verification
result = Boolean(sessionStorageGet('access_token', ''));
return result;
}
/**
* Returns event handler to Logout current user
* @returns {function} calling this event logs out current user
*/
export function useEventLogout() {
const [, dispatch] = useAppStore();
return useCallback(() => {
// TODO: AUTH: replace next line with access token saving
sessionStorageDelete('access_token');
dispatch({ type: 'LOG_OUT' });
}, [dispatch]);
}