'use client' /** * PDF Preview Modal for Abitur Documents * Shows PDF iframe with metadata sidebar */ import { X, Download, ExternalLink, FileText, Calendar, BookOpen, Layers, Search } from 'lucide-react' import { AbiturDokument, formatFileSize, formatDocumentTitle, FAECHER, NIVEAUS } from '@/lib/education/abitur-docs-types' interface PDFPreviewModalProps { document: AbiturDokument | null onClose: () => void backendUrl?: string } export function PDFPreviewModal({ document, onClose, backendUrl = '' }: PDFPreviewModalProps) { if (!document) return null const fachLabel = FAECHER.find(f => f.id === document.fach)?.label || document.fach const niveauLabel = NIVEAUS.find(n => n.id === document.niveau)?.label || document.niveau // Build PDF URL - try backend first, fall back to direct path const pdfUrl = backendUrl ? `${backendUrl}/api/abitur-docs/${document.id}/file` : document.file_path const handleDownload = () => { const link = window.document.createElement('a') link.href = pdfUrl link.download = document.dateiname link.click() } const handleSearchInRAG = () => { // Navigate to edu-search with document as context window.location.href = `/education/edu-search?doc=${document.id}&search=1` } return (