Skip to content

Instantly share code, notes, and snippets.

@sankalpsingha
Created March 27, 2017 07:45
Show Gist options
  • Save sankalpsingha/8320eb6f57f247b05f2f023e0eff78a6 to your computer and use it in GitHub Desktop.
Save sankalpsingha/8320eb6f57f247b05f2f023e0eff78a6 to your computer and use it in GitHub Desktop.
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