"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ApiSpecSelector = void 0;

var _react = _interopRequireDefault(require("react"));

var _components = require("@looker/components");

var _reactRouterDom = require("react-router-dom");

var _reactRedux = require("react-redux");

var _state = require("../../state");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var ApiSpecSelector = _ref => {
  var {
    spec
  } = _ref;
  var history = (0, _reactRouterDom.useHistory)();
  var location = (0, _reactRouterDom.useLocation)();
  var specs = (0, _reactRedux.useSelector)(_state.selectSpecs);
  var options = Object.entries(specs).map(_ref2 => {
    var [key, spec] = _ref2;
    return {
      value: key,
      label: key,
      description: spec.status
    };
  });

  var handleChange = specKey => {
    var matchPath = location.pathname.replace("/".concat(spec.key), "/".concat(specKey));
    history.push(matchPath);
  };

  return _react.default.createElement(_components.Select, {
    width: "10rem",
    "aria-label": "spec selector",
    defaultValue: spec.key,
    options: options,
    onChange: handleChange
  });
};

exports.ApiSpecSelector = ApiSpecSelector;
//# sourceMappingURL=ApiSpecSelector.js.map