import React ,{ useState } from 'react';
import { Tooltip } from 'antd';
import { CopyToClipboard } from 'react-copy-to-clipboard';


function Copy({ children , value }){
  const [ title , setTitle ] = useState("点击复制链接");
  let host = window.location.hostname === "localhost" ? "testforgeplus.trustie.net" : window.location.hostname;
  let protocol = window.location.protocol;
  return(
    <CopyToClipboard text={`${protocol}//${host}${value}`}
      onCopy={() => setTitle("复制成功")}>
      <Tooltip
        placement="bottom"
        title={title}
      >
      {children}
      </Tooltip>
    </CopyToClipboard>
  )
}
export default Copy;