{"size": 768, "ext": "js", "max_stars_repo_path": "web/src/store/reducers/auth.js", "max_stars_repo_name": "krav6/watchalong", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "web/src/store/reducers/auth.js", "max_issues_repo_name": "krav6/watchalong", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "web/src/store/reducers/auth.js", "max_forks_repo_name": "krav6/watchalong", "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": 19.6923076923, "max_line_length": 54, "alphanum_fraction": 0.60546875}
import * as actionTypes from '../actions/actionTypes';

export const initialState = {
  errorMessage: null,
  isLoading: false,
  token: null
};

const reducer = (state = initialState, action) => {
  switch (action.type) {
    case actionTypes.AUTH_SET_ERROR:
      return {
        ...state,
        errorMessage: action.payload.errorMessage,
        isLoading: false
      };

    case actionTypes.AUTH_SET_LOADING:
      return {
        ...state,
        errorMessage: null,
        isLoading: action.payload.isLoading
      };

    case actionTypes.AUTH_SET_TOKEN:
      return {
        ...state,
        errorMessage: null,
        isLoading: false,
        token: action.payload.token
      };

    default:
      return state;
  }
};

export default reducer;
