{"size": 753, "ext": "js", "max_stars_repo_path": "src/reducers/expanded-mobile-menu-options.js", "max_stars_repo_name": "adamjubert/code-gov-front-end", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/reducers/expanded-mobile-menu-options.js", "max_issues_repo_name": "adamjubert/code-gov-front-end", "max_issues_repo_issues_event_min_datetime": "2022-02-15T04:23:29.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-28T01:38:45.000Z", "max_forks_repo_path": "src/reducers/expanded-mobile-menu-options.js", "max_forks_repo_name": "adamjubert/code-gov-front-end", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 4, "max_forks_count": null, "avg_line_length": 27.8888888889, "max_line_length": 56, "alphanum_fraction": 0.6799468792}
import {
  COLLAPSE_ALL_MOBILE_MENU_OPTIONS,
  COLLAPSE_MOBILE_MENU_OPTION,
  EXPAND_MOBILE_MENU_OPTION,
  TOGGLE_MOBILE_MENU_OPTION
} from 'constants/actions';

export default function (state = null, action) {
  switch(action.type) {
    case COLLAPSE_ALL_MOBILE_MENU_OPTIONS:
      return []
    case EXPAND_MOBILE_MENU_OPTION:
      // there can only be one option expanded at once
      return state = [action.name]
    case COLLAPSE_MOBILE_MENU_OPTION:
      return [].filter(name => name !== action.name)
    case TOGGLE_MOBILE_MENU_OPTION:
      if (state.includes(action.name)) {
        return []
      } else {
        // there can only be one option expanded at once
        return [action.name]
      }
    default:
      return state;
  }
}