/** * Komponent odpowiedzialny za generowanie i eksport widoku do pliku PDF. * * Odpowiada za: * - opakowanie przekazanej treści w strukturę raportu, * - integrację z mechanizmem eksportu PDF po stronie klienta, * - obsługę akcji rozpoczęcia i zakończenia eksportu. */ import React, { useRef } from 'react'; import { usePDFExport } from '../app/hooks/usePDFExport'; interface PDFGeneratorProps { children: React.ReactNode; title?: string; fileName?: string; showButton?: boolean; buttonText?: string; buttonClass?: string; onExportStart?: () => void; onExportEnd?: () => void; } const PDFGenerator: React.FC = ({ children, title = 'ThruScan_Analysis', fileName = 'ThruScan_Analysis', showButton = true, buttonText = 'Eksportuj do PDF', buttonClass = 'bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600', onExportStart, onExportEnd }) => { const contentRef = useRef(null); const handleExportPDF = usePDFExport(contentRef, { title }); const handlePrint = async () => { onExportStart?.(); try { await handleExportPDF(); } finally { onExportEnd?.(); } }; return (
{showButton && (
)}

{title}

Wygenerowano: {new Date().toLocaleDateString('pl-PL')}
{children}
); }; export default PDFGenerator;