import { EMPTY_TOAST } from '../common/AppToast/ToastMessage';
export var UserStatus;
(function (UserStatus) {
    UserStatus["ACTIVE"] = "ACTIVE";
    UserStatus["INACTIVE"] = "INACTIVE";
    UserStatus["SUPER"] = "SUPER";
})(UserStatus || (UserStatus = {}));
export const sessionActionTypes = {
    MESSAGE: 'MESSAGE',
    TOAST_LOADING: 'TOAST_LOADING',
    SILENT_LOADING: 'SILENT_LOADING',
    LOGGED: 'LOGGED',
};
export const initialSessionState = {
    logged: undefined,
    message: EMPTY_TOAST,
    toastLoading: false,
    silentLoading: false,
};
export function sessionReducer(state, action) {
    switch (action.type) {
        case sessionActionTypes.LOGGED:
            return { ...state, logged: action.payload };
        case sessionActionTypes.MESSAGE:
            return { ...state, message: action.payload };
        case sessionActionTypes.TOAST_LOADING:
            if (typeof action.payload === 'boolean') {
                return {
                    ...state,
                    toastLoading: action.payload,
                    toastLoadingText: undefined,
                };
            }
            {
                const p = action.payload;
                return {
                    ...state,
                    toastLoading: p.loading,
                    toastLoadingText: p.text,
                };
            }
        case sessionActionTypes.SILENT_LOADING:
            return { ...state, silentLoading: action.payload };
        default:
            return state;
    }
}
export const loggedAction = (data) => ({
    type: sessionActionTypes.LOGGED,
    payload: data,
});
export const messageAction = (data) => ({
    type: sessionActionTypes.MESSAGE,
    payload: data,
});
export const toastLoadingAction = (data) => ({
    type: sessionActionTypes.TOAST_LOADING,
    payload: data,
});
export const silentLoadingAction = (data) => ({
    type: sessionActionTypes.SILENT_LOADING,
    payload: data,
});
