import { CheckCircleFilled, ExclamationCircleFilled } from "@ant-design/icons";
import { Modal } from "antd";

export default function PrerequisiteVerifyModal({
  open,
  result,
  loading,
  onCancel,
  onConfirm,
}) {
  const allPassed = result?.passed;

  return (
    <Modal
      open={open}
      title="资质申请前置条件核验结果"
      width={560}
      destroyOnHidden
      onCancel={onCancel}
      onOk={allPassed ? onConfirm : undefined}
      okText="确定"
      cancelText={allPassed ? "取消" : "关闭"}
      confirmLoading={loading}
      okButtonProps={{ style: allPassed ? undefined : { display: "none" } }}
    >
      <div style={{ padding: "8px 0" }}>
        {(result?.items || []).map((item) => (
          <div
            key={item.key}
            style={{
              display: "flex",
              gap: 12,
              alignItems: "flex-start",
              marginBottom: 16,
            }}
          >
            {item.passed ? (
              <CheckCircleFilled style={{ color: "#52c41a", fontSize: 18, marginTop: 2 }} />
            ) : (
              <ExclamationCircleFilled style={{ color: "#faad14", fontSize: 18, marginTop: 2 }} />
            )}
            <div>
              <div style={{ fontWeight: 600, marginBottom: 4 }}>{item.label}</div>
              <div style={{ color: "rgba(0,0,0,0.65)", lineHeight: 1.6 }}>{item.desc}</div>
            </div>
          </div>
        ))}
      </div>
    </Modal>
  );
}
