'use client';

/**
 * 공정 작업일지 미리보기 모달
 *
 * document-system 통합 버전 (2026-01-22)
 */

import { DocumentViewer } from '@/components/document-system';
import type { Process } from '@/types/process';
import { ProcessWorkLogContent } from './ProcessWorkLogContent';

const getDocumentCode = (processName: string): string => {
  if (processName.includes('스크린')) return 'WL-SCR';
  if (processName.includes('슬랫')) return 'WL-SLT';
  if (processName.includes('절곡') || processName.includes('포밍')) return 'WL-BEN';
  return 'WL-STK';
};

interface ProcessWorkLogPreviewModalProps {
  open: boolean;
  onOpenChange: (open: boolean) => void;
  process: Process;
}

export function ProcessWorkLogPreviewModal({
  open,
  onOpenChange,
  process
}: ProcessWorkLogPreviewModalProps) {
  const documentCode = getDocumentCode(process.processName);

  return (
    <DocumentViewer
      title={`${process.workLogTemplate} 미리보기`}
      subtitle={`(${documentCode})`}
      preset="inspection"
      open={open}
      onOpenChange={onOpenChange}
    >
      <ProcessWorkLogContent data={process} />
    </DocumentViewer>
  );
}
