{"size": 695, "ext": "js", "max_stars_repo_path": "src/reducers/registerReducer/index.js", "max_stars_repo_name": "JamesMudidi/React", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/reducers/registerReducer/index.js", "max_issues_repo_name": "JamesMudidi/React", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/reducers/registerReducer/index.js", "max_forks_repo_name": "JamesMudidi/React", "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": 17.8205128205, "max_line_length": 59, "alphanum_fraction": 0.5625899281}
import {
  AUTHENTICATE,
  REGISTER_SUCCESS,
  REGISTER_FAIL,
} from '../../actions/types';

const initialState = {
  isLoading: false,
  isLoggedin: false,
  user: {},
};

const registerReducer = (state = initialState, action) => {
  switch (action.type) {
    case AUTHENTICATE:
      return {
        ...state,
        isLoading: true,
      };
    case REGISTER_SUCCESS:
      return {
        ...state,
        isLoading: false,
        isLoggedin: true,
        user: action.payload,
      };
    case REGISTER_FAIL:
      return {
        ...state,
        isLoading: false,
        isLoggedin: false,
      };
    default:
      return { state };
  }
};

export default registerReducer;
