{"size": 801, "ext": "js", "max_stars_repo_path": "essentialism/src/store/reducers/users.js", "max_stars_repo_name": "build-week-essentialism/essentialism-frontend-james", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "essentialism/src/store/reducers/users.js", "max_issues_repo_name": "build-week-essentialism/essentialism-frontend-james", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "essentialism/src/store/reducers/users.js", "max_forks_repo_name": "build-week-essentialism/essentialism-frontend-james", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.025, "max_line_length": 63, "alphanum_fraction": 0.54556804}
import * as actionTypes from '../actions/index.js';

const initialState = {
  login_loading: false,
  error: "",
  message: "",
  user:{}
}

export const UsersReducer = (state = initialState, action) => {
  switch(action.type){
    // Login
    case actionTypes.LOGIN_LOADING:
      return {
        ...state,
        login_loading: true,
        message: "",
        error: ""
      }
    case actionTypes.LOGIN_SUCCESS:
      return {
        ...state,
        login_loading: false,
        error: "",
        message: action.payload.message,
        user: action.payload.user
      }
    case actionTypes.LOGIN_FAILURE:
      return {
        ...state,
        login_loading: false,
        error: action.payload,
        message: "",
        user: {}
      }

    default:
      return state
  }
}