{"size": 991, "ext": "js", "max_stars_repo_path": "src/store/reducers/search.js", "max_stars_repo_name": "netgenlayouts/content-browser-ui", "max_stars_repo_stars_event_min_datetime": "2018-10-10T05:33:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-05T12:24:57.000Z", "max_issues_repo_path": "src/store/reducers/search.js", "max_issues_repo_name": "netgenlayouts/content-browser-ui", "max_issues_repo_issues_event_min_datetime": "2020-02-07T15:15:45.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-07T15:15:45.000Z", "max_forks_repo_path": "src/store/reducers/search.js", "max_forks_repo_name": "netgen-layouts/content-browser-ui", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 13, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 16.5166666667, "max_line_length": 51, "alphanum_fraction": 0.5560040363}
import {
  START_SEARCH_LOAD,
  STOP_SEARCH_LOAD,
  SET_SEARCH_TERM,
  FETCH_SEARCH,
  SET_SEARCH_PAGE,
  SET_SEARCH_PREVIEW_ITEM,
} from '../actionTypes';

const INITIAL_STATE = {
  isLoading: false,
  items: {},
  searchTerm: '',
  currentPage: 1,
  previewItem: '',
};

export default (state = INITIAL_STATE, action) => {
  switch (action.type) {
    case START_SEARCH_LOAD:
      return {
        ...state,
        isLoading: true,
      };

    case STOP_SEARCH_LOAD:
      return {
        ...state,
        isLoading: false,
      };

    case SET_SEARCH_TERM:
      return {
        ...state,
        searchTerm: action.term,
      };

    case FETCH_SEARCH:
      return {
        ...state,
        items: action.items,
      };

    case SET_SEARCH_PAGE:
      return {
        ...state,
        currentPage: action.page,
      };

    case SET_SEARCH_PREVIEW_ITEM:
      return {
        ...state,
        previewItem: action.id,
      };

    default:
      return state;
  }
};
