{"size": 894, "ext": "js", "max_stars_repo_path": "app/containers/Skeleton/reducer.js", "max_stars_repo_name": "XaviTorello/react-plugins-boilerplate", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/containers/Skeleton/reducer.js", "max_issues_repo_name": "XaviTorello/react-plugins-boilerplate", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/containers/Skeleton/reducer.js", "max_forks_repo_name": "XaviTorello/react-plugins-boilerplate", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 17.88, "max_line_length": 52, "alphanum_fraction": 0.5637583893}
/*
 *
 * Header reducer
 *
 */

import { fromJS } from 'immutable';

import { CHANGE_MENU } from './constants';

import { MENU } from './actions';

import * as initial from './initialState';

export const initialState = fromJS({
  ...initial,
});

function menuReducer(state = initialState, action) {
  switch (action.type) {
    case CHANGE_MENU:
      return state.set('menu', action.menu);

    /* ///////////
    //  MENU!  //
    /////////// */

    case MENU.REQUEST:
      return state
        .set('loading', true)
        .set('error', false);

    case MENU.SUCCESS:
      return state
        .set('loading', false)
        .set('error', false)
        .set('menu', fromJS(action.menu))

    case MENU.FAILURE:
      return state
        .set('loading', false)
        .set('error', action.error.message || true);

    default:
      return state;
  }
}

export default menuReducer;
