{"size": 738, "ext": "js", "max_stars_repo_path": "src/reducers/infoReducer.js", "max_stars_repo_name": "AnnadataHackfest/ReactWebsite", "max_stars_repo_stars_event_min_datetime": "2021-05-15T05:54:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-15T05:54:07.000Z", "max_issues_repo_path": "src/reducers/infoReducer.js", "max_issues_repo_name": "AnnadataHackfest/ReactWebsite", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/reducers/infoReducer.js", "max_forks_repo_name": "AnnadataHackfest/ReactWebsite", "max_forks_repo_forks_event_min_datetime": "2021-05-04T06:41:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-04T06:41:19.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 18.45, "max_line_length": 73, "alphanum_fraction": 0.5433604336}
import {
  GET_INFOS,
  ADD_INFO,
  DELETE_INFO,
  INFOS_LOADING,
} from '../actions/types';

const initialState = {
  infos: [],
  loading: false,
};

export default function infoReducer(state = initialState, action) {
  switch (action.type) {
    case GET_INFOS:
      return {
        ...state,
        infos: action.payload,
        loading: false,
      };
    case DELETE_INFO:
      return {
        ...state,
        infos: state.items.filter((item) => item._id !== action.payload),
      };
    case ADD_INFO:
      return {
        ...state,
        infos: [action.payload, ...state.infos],
      };
    case INFOS_LOADING:
      return {
        ...state,
        loading: true,
      };
    default:
      return state;
  }
}
