import React from 'react';
import { injectIntl } from 'react-intl';
import { getEnvStatus } from "../status-dot";
import StatusTag from "../status-tag";
import "./index.less";

function EnvDetail(_ref) {
  var record = _ref.record,
      formatMessage = _ref.intl.formatMessage,
      isRecord = _ref.isRecord;
  var data = record;

  if (isRecord) {
    data = record ? record.toData() : null;
  }

  var _ref2 = data || {},
      name = _ref2.name,
      connect = _ref2.connect,
      synchronize = _ref2.synchronize,
      synchro = _ref2.synchro,
      active = _ref2.active,
      code = _ref2.code,
      description = _ref2.description,
      clusterName = _ref2.clusterName;

  var status = data ? getEnvStatus({
    connect: connect,
    synchronize: synchronize || synchro,
    active: active
  }) : '';
  return /*#__PURE__*/React.createElement("ul", {
    className: "c7ncd-env-detail"
  }, /*#__PURE__*/React.createElement("li", {
    className: "c7ncd-env-detail-item"
  }, /*#__PURE__*/React.createElement("span", {
    className: "c7ncd-env-detail-item-text"
  }, formatMessage({
    id: 'c7ncd.env.name'
  })), /*#__PURE__*/React.createElement("span", {
    className: "c7ncd-env-detail-item-value"
  }, name)), /*#__PURE__*/React.createElement("li", {
    className: "c7ncd-env-detail-item"
  }, /*#__PURE__*/React.createElement("span", {
    className: "c7ncd-env-detail-item-text"
  }, formatMessage({
    id: 'c7ncd.env.status'
  })), status && /*#__PURE__*/React.createElement(StatusTag, {
    name: formatMessage({
      id: status
    }),
    colorCode: status
  })), /*#__PURE__*/React.createElement("li", {
    className: "c7ncd-env-detail-item"
  }, /*#__PURE__*/React.createElement("span", {
    className: "c7ncd-env-detail-item-text"
  }, formatMessage({
    id: 'c7ncd.env.code'
  })), /*#__PURE__*/React.createElement("span", {
    className: "c7ncd-env-detail-item-value"
  }, code)), /*#__PURE__*/React.createElement("li", {
    className: "c7ncd-env-detail-item"
  }, /*#__PURE__*/React.createElement("span", {
    className: "c7ncd-env-detail-item-text"
  }, formatMessage({
    id: 'c7ncd.env.description'
  })), /*#__PURE__*/React.createElement("span", {
    className: "c7ncd-env-detail-item-value"
  }, description)), /*#__PURE__*/React.createElement("li", {
    className: "c7ncd-env-detail-item"
  }, /*#__PURE__*/React.createElement("span", {
    className: "c7ncd-env-detail-item-text"
  }, formatMessage({
    id: 'c7ncd.env.cluster'
  })), /*#__PURE__*/React.createElement("span", {
    className: "c7ncd-env-detail-item-value"
  }, clusterName)));
}

EnvDetail.defaultProps = {
  isRecord: true
};
export default injectIntl(EnvDetail);