Created
March 27, 2017 07:45
-
-
Save sankalpsingha/8320eb6f57f247b05f2f023e0eff78a6 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
const INITIAL_STATE = { | |
email: '', | |
password: '', | |
authentication_token: '', | |
username: '', | |
errorFlag: false, | |
spinner: false | |
}; | |
export default (state = INITIAL_STATE, action) => { | |
switch (action.type) { | |
case 'EMAIL_CHANGED': | |
return { ...state, email: action.payload }; | |
case 'PASSWORD_CHANGED': | |
return { ...state, password: action.payload }; | |
case 'LOGIN_FAILED': | |
return { ...state, errorFlag: true, password: '', spinner: false }; | |
case 'LOGIN_USER_SUCCESS': | |
return { ...state, ...action.payload, ...INITIAL_STATE }; | |
case 'LOAD_SPINNER': | |
return { ...state, spinner: true }; | |
default: | |
return state; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment