{"size": 883, "ext": "js", "max_stars_repo_path": "app/containers/gif/reducer.js", "max_stars_repo_name": "astrogif/astrogif", "max_stars_repo_stars_event_min_datetime": "2017-02-28T02:41:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-13T01:04:46.000Z", "max_issues_repo_path": "app/containers/gif/reducer.js", "max_issues_repo_name": "astrogif/astrogif", "max_issues_repo_issues_event_min_datetime": "2017-01-15T20:52:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-25T18:43:56.000Z", "max_forks_repo_path": "app/containers/gif/reducer.js", "max_forks_repo_name": "jamesmacfie/astrogif", "max_forks_repo_forks_event_min_datetime": "2017-01-18T19:52:46.000Z", "max_forks_repo_forks_event_max_datetime": "2017-10-18T03:19:54.000Z"}
{"max_stars_count": 9, "max_issues_count": 35, "max_forks_count": 3, "avg_line_length": 18.7872340426, "max_line_length": 63, "alphanum_fraction": 0.5481313703}
import GIF from './constants';
import APP from '../app/constants';

const initialState = {
  error: null,
  fetching: false,
  currentQuery: null
};


export default function reducer(state = initialState, action) {
  switch (action.type) {
    case GIF.QUERY:
      return {
        error: null,
        fetching: false,
        details: null,
        currentQuery: action.payload
      };
    case GIF.NEXT:
    case GIF.REQUEST:
      return {
        ...state,
        error: null,
        fetching: true,
        details: null
      };
    case GIF.RESULT:
      return {
        ...state,
        fetching: false,
        details: action.payload
      };
    case GIF.ERROR:
      return {
        ...state,
        error: action.payload,
        fetching: false
      };
    case GIF.CLEAR:
    case APP.RESET:
      return initialState;
    default:
      return state;
  }
}
