Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 32 | Ir a la última revisión | | Ultima modificación | Ver Log |

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