import { useState, useEffect } from 'react'; import { Download, FileText, Check, ExternalLink, Eye, Search, ChevronLeft, ChevronRight, ZoomIn, ZoomOut, BarChart3 } from 'lucide-react'; import { Document, Page, pdfjs } from 'react-pdf'; // Core PDF.js styles import 'react-pdf/dist/Page/AnnotationLayer.css'; import 'react-pdf/dist/Page/TextLayer.css'; // Configure PDF worker pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.mjs`; const MOBILE_BREAKPOINT = 1100; function DocumentPreview({ cv, textContent, isPdf, onDownloadCV, analysisResult, scoreBefore, job, onBack }) { const [isMobile, setIsMobile] = useState(window.innerWidth < MOBILE_BREAKPOINT); const [numPages, setNumPages] = useState(null); const [pageNumber, setPageNumber] = useState(1); const [scale, setScale] = useState(1.0); useEffect(() => { const handleResize = () => setIsMobile(window.innerWidth < MOBILE_BREAKPOINT); window.addEventListener('resize', handleResize); return () => window.removeEventListener('resize', handleResize); }, []); function onDocumentLoadSuccess({ numPages }) { setNumPages(numPages); } const tone = analysisResult?.score >= 80 ? 'success' : 'warning'; const gained = scoreBefore != null && analysisResult?.score > scoreBefore ? analysisResult.score - scoreBefore : 0; // Optimization report sidebar (also the whole view on mobile) const report = (

Optimization report

{analysisResult && ( <>
Match score
{analysisResult.score}% {gained > 0 && +{gained} from {scoreBefore}%}
{analysisResult.matching_skills?.length > 0 && (
Skills highlighted
    {analysisResult.matching_skills.slice(0, 8).map((skill, i) => (
  • {skill}
  • ))}
)} )}
{isMobile && isPdf && ( View CV )} {job && ( Apply for this job )}
); // Mobile Layout - report and actions without embedded PDF if (isMobile) { return (
{report}
); } // Desktop Layout return (
{/* Sidebar / Stats */} {report} {/* Document Preview (React-PDF) */}
Tailored CV {isPdf && numPages && ( · Page {pageNumber} of {numPages} )} {isPdf && (
{Math.round(scale * 100)}% )}
{isPdf ? ( Loading preview…
} error={

Couldn't load the PDF preview.

Download instead
} > ) : (
{textContent}
)}
{isPdf && numPages && numPages > 1 && (
{pageNumber} / {numPages}
)}
); } export default DocumentPreview;