{"size": 691, "ext": "js", "max_stars_repo_path": "src/client/store/reducers/articlesReducer.js", "max_stars_repo_name": "bbrinx/newsfeed", "max_stars_repo_stars_event_min_datetime": "2018-09-12T13:36:05.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-24T05:48:06.000Z", "max_issues_repo_path": "src/client/store/reducers/articlesReducer.js", "max_issues_repo_name": "bbrinx/newsfeed", "max_issues_repo_issues_event_min_datetime": "2019-11-10T17:06:25.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T05:43:35.000Z", "max_forks_repo_path": "src/client/store/reducers/articlesReducer.js", "max_forks_repo_name": "bbrinx/newsfeed", "max_forks_repo_forks_event_min_datetime": "2019-01-31T16:03:42.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-06T06:43:12.000Z"}
{"max_stars_count": 4, "max_issues_count": 7, "max_forks_count": 2, "avg_line_length": 28.7916666667, "max_line_length": 128, "alphanum_fraction": 0.6874095514}
import { articlesActionTypes } from '../actions';

const Status = {
  IDLE: 'idle',
  PENDING: 'pending',
  SUCCESS: 'success',
  FAILURE: 'failure'
};

const initialState = {
  articles: [],
  status: Status.IDLE
};

const reducer = (state = initialState, action) => {
  switch (action.type) {
    case articlesActionTypes.FETCH_ARTICLES: return { ...state, status: Status.PENDING };
    case `${articlesActionTypes.FETCH_ARTICLES}_SUCCESS`: return { ...state, articles: action.payload, status: Status.SUCCESS };
    case `${articlesActionTypes.FETCH_ARTICLES}_FAILURE`:  return { ...state, status: action.payload };
    default: return state;
  }
};

export { reducer as articlesReducer };