/**
 * KRA - PDF Viewer Component
 * Display PDF files using iframe or embed
 */
import React from 'react';
import { Empty, Spin } from 'antd';

interface PDFViewerProps {
  url?: string;
  width?: string | number;
  height?: string | number;
  loading?: boolean;
  className?: string;
  style?: React.CSSProperties;
}

const PDFViewer: React.FC<PDFViewerProps> = ({
  url,
  width = '100%',
  height = 600,
  loading = false,
  className,
  style,
}) => {
  if (!url) {
    return <Empty description="暂无PDF文件" />;
  }

  return (
    <Spin spinning={loading}>
      <iframe
        src={url}
        className={className}
        style={{
          width: typeof width === 'number' ? `${width}px` : width,
          height: typeof height === 'number' ? `${height}px` : height,
          border: 'none',
          ...style,
        }}
        title="PDF Viewer"
      />
    </Spin>
  );
};

export default PDFViewer;
