Rev 3396 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
import { actionsTypes } from './auth.types';
const initialState = {
access_usign_social_networks: 'y',
aes: '',
defaultNetwork: 'y',
email: '',
favico_url: '',
intro: '',
logo_url: '',
navbar_url: '',
remember: true,
site_key: '',
is_logged_in: false,
theme_id: '1',
jwt: '',
loading: true
};
const AuthReducer = (state = initialState, action) => {
const { type, payload } = action;
const actionCases = {
[actionsTypes.SET_CREDENTIALS]: { ...state, ...payload },
[actionsTypes.LOGIN]: { ...state, is_logged_in: true },
[actionsTypes.LOGOUT]: { ...state, is_logged_in: false },
[actionsTypes.START_LOADING]: { ...state, loading: true },
[actionsTypes.STOP_LOADING]: { ...state, loading: false }
};
return actionCases[type] || state;
};
export default AuthReducer;