{"size": 612, "ext": "js", "max_stars_repo_path": "src/reducers/comments.js", "max_stars_repo_name": "billhanyu/blog", "max_stars_repo_stars_event_min_datetime": "2019-05-26T05:32:29.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-26T05:32:29.000Z", "max_issues_repo_path": "src/reducers/comments.js", "max_issues_repo_name": "billhanyu/blog", "max_issues_repo_issues_event_min_datetime": "2018-05-21T20:36:25.000Z", "max_issues_repo_issues_event_max_datetime": "2018-06-01T14:11:58.000Z", "max_forks_repo_path": "src/reducers/comments.js", "max_forks_repo_name": "billhanyu/blog", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 6, "max_forks_count": null, "avg_line_length": 17.4857142857, "max_line_length": 43, "alphanum_fraction": 0.5506535948}
import {
  REQUEST_COMMENTS,
  RECEIVE_COMMENTS,
  POST_COMMENT,
} from '../actions/actionTypes';

function comments(state={
  all: [],
  error: '',
  postError: '',
}, action) {
  switch (action.type) {
    case REQUEST_COMMENTS:
      return {
        all: [],
        error: '',
      };
    case RECEIVE_COMMENTS:
      return {
        ...state,
        all: action.payload.comments || [],
        error: action.payload.error,
      };
    case POST_COMMENT:
      return {
        ...state,
        postError: action.payload.error,
      };
    default:
      return state;
  }
}

export default comments;
