import React from "react";
import PropTypes from "prop-types";
import { Typography, Descriptions, Flex } from "antd";
import CopyButton from "./CopyButton";
import BoolDislay from "./BoolDisplay";
import StateDislay from "./StateDisplay";

const { Text } = Typography;

const HostInformation = ({ host, bordered, size, column }) => {
  return (
    <Descriptions
      bordere={bordered}
      size={size}
      column={column}
      items={[
        {
          label: "ID",
          children: (
            <Flex style={{ minWidth: 0 }}>
              <Text code ellipsis>
                HST:{host?._id}
              </Text>
              <CopyButton />
            </Flex>
          ),
        },
        {
          label: "Name",
          children: <Text>{host?.name}</Text>,
        },
        {
          label: "Active",
          children: <BoolDislay value={host?.active} yesNo={true} />,
        },
        {
          label: "State",
          children: <StateDislay state={host?.state} />,
        },
        {
          label: "OS Platform",
          children: <Text>{host?.deviceInfo?.os?.platform}</Text>,
        },
        {
          label: "OS Type",
          children: <Text>{host?.deviceInfo?.os?.type}</Text>,
        },
        {
          label: "OS Release",
          children: <Text>{host?.deviceInfo?.os?.release}</Text>,
        },
        {
          label: "Arch",
          children: <Text>{host?.deviceInfo?.os?.arch}</Text>,
        },
        {
          label: "Hostname",
          children: <Text>{host?.deviceInfo?.os?.hostname}</Text>,
        },
        {
          label: "CPU Model",
          children: <Text>{host?.deviceInfo?.cpu?.model}</Text>,
        },
        {
          label: "CPU Cores",
          children: <Text>{host?.deviceInfo?.cpu?.cores}</Text>,
        },
        {
          label: "CPU Speed",
          children: <Text>{host?.deviceInfo?.cpu?.speedMHz}MHz</Text>,
        },
      ]}
    />
  );
};

HostInformation.propTypes = {
  text: PropTypes.string.isRequired,
  style: PropTypes.object,
  tooltip: PropTypes.string,
  size: PropTypes.string,
  type: PropTypes.string,
};

export default HostInformation;
