'use client';

/**
 * 제품검사성적서 모달
 * DocumentViewer를 사용하여 문서 표시 + 인쇄/PDF 기능 제공
 */

import { Save } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { DocumentViewer } from '@/components/document-system';
import { InspectionReportDocument } from './InspectionReportDocument';
import type { InspectionReportDocument as InspectionReportDocumentType } from '../types';

interface InspectionReportModalProps {
  open: boolean;
  onOpenChange: (open: boolean) => void;
  data: InspectionReportDocumentType | null;
  onSave?: () => void;
}

export function InspectionReportModal({
  open,
  onOpenChange,
  data,
  onSave,
}: InspectionReportModalProps) {
  if (!data) return null;

  return (
    <DocumentViewer
      title="제품검사성적서"
      preset="readonly"
      open={open}
      onOpenChange={onOpenChange}
      pdfMeta={{
        documentNumber: data.documentNumber,
        createdDate: data.createdDate,
      }}
      toolbarExtra={
        <Button onClick={onSave} size="sm">
          <Save className="w-4 h-4 mr-1.5" />
          저장
        </Button>
      }
    >
      <InspectionReportDocument data={data} />
    </DocumentViewer>
  );
}
