import React from 'react';
import { observer } from 'mobx-react-lite';
import { useResourceStore } from "../../../stores";
import "./index.less";

function ResourceListTitle(_ref) {
  var type = _ref.type;

  var _useResourceStore = useResourceStore(),
      treeDs = _useResourceStore.treeDs,
      parentId = _useResourceStore.resourceStore.getSelectedMenu.parentId,
      formatMessage = _useResourceStore.intl.formatMessage,
      intlPrefix = _useResourceStore.intlPrefix,
      prefixCls = _useResourceStore.prefixCls;

  function getEnvName() {
    var envRecord = treeDs.find(function (record) {
      return record.get('key') === parentId;
    });

    if (envRecord) {
      return envRecord.get('name');
    }
  }

  return /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-resource-list-title")
  }, formatMessage({
    id: "".concat(intlPrefix, ".env")
  }, {
    name: getEnvName()
  }), formatMessage({
    id: type || 'null'
  }));
}

export default observer(ResourceListTitle);