{"size": 1278, "ext": "js", "max_stars_repo_path": "src/reducers/ui/polls.js", "max_stars_repo_name": "g-old/g-old", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/reducers/ui/polls.js", "max_issues_repo_name": "g-old/g-old", "max_issues_repo_issues_event_min_datetime": "2020-08-11T17:23:42.000Z", "max_issues_repo_issues_event_max_datetime": "2020-08-11T17:23:42.000Z", "max_forks_repo_path": "src/reducers/ui/polls.js", "max_forks_repo_name": "g-old/g-old", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 21.3, "max_line_length": 76, "alphanum_fraction": 0.6345852895}
import {
  LOAD_VOTES_SUCCESS,
  LOAD_VOTES_START,
  LOAD_VOTES_ERROR,
  CREATE_VOTE_START,
  CREATE_VOTE_ERROR,
  CREATE_VOTE_SUCCESS,
  UPDATE_VOTE_START,
  UPDATE_VOTE_SUCCESS,
  UPDATE_VOTE_ERROR,
  DELETE_VOTE_START,
  DELETE_VOTE_SUCCESS,
  DELETE_VOTE_ERROR,
} from '../../constants';

const initState = {
  mutation: {
    success: false,
    error: '',
    pending: false,
  },
};
const polls = (state = initState, action) => {
  switch (action.type) {
    case LOAD_VOTES_SUCCESS:
    case UPDATE_VOTE_SUCCESS:
    case DELETE_VOTE_SUCCESS:
    case CREATE_VOTE_SUCCESS: {
      return {
        ...state,
        mutation: { pending: false, success: true, error: '' },
      };
    }
    case LOAD_VOTES_START:
    case UPDATE_VOTE_START:
    case DELETE_VOTE_START:
    case CREATE_VOTE_START: {
      return {
        ...state,
        mutation: { pending: true, success: false, error: '' },
      };
    }
    case LOAD_VOTES_ERROR:
    case UPDATE_VOTE_ERROR:
    case DELETE_VOTE_ERROR:
    case CREATE_VOTE_ERROR: {
      return {
        ...state,
        mutation: { pending: false, success: false, error: action.message },
      };
    }

    default:
      return state;
  }
};

export default polls;
export const getStatus = state => state.mutation || {};
