import { useContext } from 'react';
import CommonContext from './CommonContext';
import { loggedAction, UserStatus } from './sessionTypes';
export const useLoggedUtils = () => {
    const { state, dispatch } = useContext(CommonContext);
    const getLogged = () => {
        return state.logged;
    };
    const isLogged = () => {
        return state.logged !== undefined;
    };
    const isSuper = () => {
        return state.logged && state.logged.status === UserStatus.SUPER;
    };
    const setLogged = (user) => {
        dispatch(loggedAction(user));
    };
    return {
        getLogged,
        isSuper,
        isLogged,
        setLogged,
    };
};
