Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 32 | Rev 95 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
32 stevensc 1
import { actionsTypes } from "./auth.types";
5 stevensc 2
 
3
const initialState = {
32 stevensc 4
  access_usign_social_networks: "y",
5
  aes: "",
6
  defaultNetwork: "y",
7
  email: "",
8
  favico_url: "",
9
  intro: "",
10
  logo_url: "",
11
  navbar_url: "",
5 stevensc 12
  remember: true,
32 stevensc 13
  site_key: "",
5 stevensc 14
  isAuth: false,
32 stevensc 15
  theme_id: "1",
16
  jwt: "",
5 stevensc 17
  loading: true,
32 stevensc 18
};
5 stevensc 19
 
20
const AuthReducer = (state = initialState, action) => {
32 stevensc 21
  const { type, payload } = action;
5 stevensc 22
 
23
  const actionCases = {
24
    [actionsTypes.SET_PERMISSIONS]: { ...state, ...payload },
25
    [actionsTypes.LOGIN]: { ...state, isAuth: true },
94 stevensc 26
    [actionsTypes.LOGOUT]: { ...state, isAuth: false, jwt: "" },
5 stevensc 27
    [actionsTypes.START_LOADING]: { ...state, loading: true },
28
    [actionsTypes.STOP_LOADING]: { ...state, loading: false },
32 stevensc 29
  };
5 stevensc 30
 
32 stevensc 31
  return actionCases[type] || state;
32
};
5 stevensc 33
 
32 stevensc 34
export default AuthReducer;