Created
July 16, 2020 00:48
-
-
Save Soffcsr/8d19d9247c9c7de6fcd5018934834731 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LOGIN_USER, LOGIN_SUCCESS, LOGIN_ERROR, LOGOUT } from "../constants/action-types" | |
const initState = { | |
loged: false, | |
error: '', | |
credentials: { | |
token: '', | |
username: '', | |
userlastname: '' | |
} | |
} | |
const authReducer = (state = initState, action) => { | |
switch(action.type){ | |
case LOGIN_USER : | |
return { | |
credentials: action.payload, | |
loged: true | |
}; | |
case LOGIN_SUCCESS : | |
return { | |
loged: action.payload | |
}; | |
case LOGIN_ERROR : | |
return { | |
loged: false, | |
error: action.payload.error | |
}; | |
case LOGOUT : | |
return { | |
loged: false | |
} | |
default: | |
break; | |
} | |
return state | |
} | |
export default authReducer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment