Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 7370 | | Comparar con el anterior | Ultima modificación | Ver Log |

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