import { Tag, Tooltip } from "antd";
import PreviewImg from "../PreviewImg";

/**
 * 在表格组件中图片查看组件
 */
const TooltipPreviewImg = (props) => {
  const { files = [], fileUrlKey = "filePath" } = props;

  const renderContent = () => {
    return (
      files.length > 0
        ? <PreviewImg files={files} fileUrlKey={fileUrlKey} />
        : <span>暂无图片</span>
    );
  };

  return (
    <Tooltip placement="top" title={renderContent()}>
      <Tag>预览</Tag>
    </Tooltip>
  );
};

TooltipPreviewImg.displayName = "TooltipPreviewImg";

export default TooltipPreviewImg;
