/**
 * 判断结果Badge组件
 * 用于显示PICOS各维度的判断结果
 */

import { Tag, Tooltip } from 'antd';
import {
  CheckCircleOutlined,
  CloseCircleOutlined,
  ExclamationCircleOutlined,
  QuestionCircleOutlined,
} from '@ant-design/icons';
import type { JudgmentType } from '../types';

interface JudgmentBadgeProps {
  judgment: JudgmentType;
  evidence?: string | null;
  showIcon?: boolean;
}

const JudgmentBadge: React.FC<JudgmentBadgeProps> = ({
  judgment,
  evidence,
  showIcon = true,
}) => {
  // 根据判断结果返回相应的配置
  const getConfig = () => {
    switch (judgment) {
      case 'match':
        return {
          color: 'success',
          icon: <CheckCircleOutlined />,
          text: '匹配',
        };
      case 'partial':
        return {
          color: 'warning',
          icon: <ExclamationCircleOutlined />,
          text: '部分',
        };
      case 'mismatch':
        return {
          color: 'error',
          icon: <CloseCircleOutlined />,
          text: '不匹配',
        };
      default:
        return {
          color: 'default',
          icon: <QuestionCircleOutlined />,
          text: '未知',
        };
    }
  };

  const config = getConfig();

  const badge = (
    <Tag
      color={config.color}
      icon={showIcon ? config.icon : undefined}
      className="m-0"
    >
      {config.text}
    </Tag>
  );

  // 如果有证据，显示Tooltip
  if (evidence) {
    return (
      <Tooltip title={`证据: ${evidence}`} placement="top">
        {badge}
      </Tooltip>
    );
  }

  return badge;
};

export default JudgmentBadge;





