Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {AUTH_USER_REQUEST, AUTH_USER_SUCCESS, AUTH_USER_FAILURE} from './authTypes'
- const initialState = {
- loading: false,
- users: {
- },
- error: '',
- token: null
- }
- const authReducer = (state = initialState, action) => {
- switch(action.type) {
- case AUTH_USER_REQUEST:
- return {
- ...state,
- loading: true,
- token: null
- }
- case AUTH_USER_SUCCESS:
- return {
- loading: false,
- users: action.payload,
- error: '',
- token: 1
- }
- case AUTH_USER_FAILURE: return {
- loading: false,
- users: {},
- error: action.payload,
- token: null
- }
- default: return state
- }
- }
- export default authReducer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement