diff --git a/app/mission-control/pdf-viewer/page.tsx b/app/mission-control/pdf-viewer/page.tsx index d7a4cfd..30baf0b 100644 --- a/app/mission-control/pdf-viewer/page.tsx +++ b/app/mission-control/pdf-viewer/page.tsx @@ -1,69 +1,22 @@ "use client"; import BackToMC from "@/components/mission-control/BackToMC"; -import { useState } from "react"; +import dynamic from "next/dynamic"; + +// Dynamically import PDFViewer with SSR disabled +const PDFViewer = dynamic(() => import("@/components/mission-control/PDFViewerClient"), { + ssr: false, + loading: () => ( +
+
+
+

Loading PDF viewer...

+
+
+ ), +}); export default function PdfViewerPage() { - const [pdfData, setPdfData] = useState(null); - const [pdfName, setPdfName] = useState(""); - const [loading, setLoading] = useState(false); - const [error, setError] = useState(null); - const [viewMode, setViewMode] = useState<"embed" | "download">("embed"); - - const handleFileUpload = async (e: React.ChangeEvent) => { - const file = e.target.files?.[0]; - if (!file) return; - - if (file.type !== "application/pdf") { - setError("Please select a PDF file"); - return; - } - - setLoading(true); - setError(null); - setPdfName(file.name); - - const reader = new FileReader(); - reader.onload = (event) => { - const base64 = event.target?.result as string; - setPdfData(base64); - setLoading(false); - }; - reader.onerror = () => { - setError("Failed to read file"); - setLoading(false); - }; - reader.readAsDataURL(file); - }; - - const handleUrlSubmit = async () => { - const input = prompt("Enter PDF URL:"); - if (!input) return; - - setLoading(true); - setError(null); - - try { - new URL(input); - // Use Google Docs viewer for external URLs - const googleViewerUrl = `https://docs.google.com/gview?url=${encodeURIComponent(input)}&embedded=true`; - setPdfData(googleViewerUrl); - setPdfName(input.split("/").pop() || "document.pdf"); - setLoading(false); - } catch { - setError("Invalid URL"); - setLoading(false); - } - }; - - const handleDownload = () => { - if (!pdfData) return; - const link = document.createElement("a"); - link.href = pdfData; - link.download = pdfName || "document.pdf"; - link.click(); - }; - return (
{/* Header */} @@ -72,131 +25,9 @@ export default function PdfViewerPage() {

View and analyze PDF documents

- {/* Toolbar */} -
-
- - - - - {pdfData && ( - <> - - - {pdfData.startsWith("data:") && ( - - ↗ Open in New Tab - - )} - - )} -
-
- {/* Content */} -
- {error && ( -
-

Error

-

{error}

- -
- )} - - {!pdfData && !loading && ( -
-
-
📄
-

No PDF Loaded

-

Upload a PDF or enter a URL to view it

-
-

• Upload your resume to let Horus analyze it

-

• Supports PDF files up to 50MB

-

• Or load from any public PDF URL

-
-
-
- )} - - {loading && ( -
-
-
-

Loading PDF...

-
-
- )} - - {pdfData && !loading && ( -
- {pdfData.startsWith("data:") ? ( - // For uploaded files, show download prompt since browser PDF rendering in iframe is blocked -
-
📄
-

{pdfName}

-

PDF loaded successfully

-
- - - ↗ Open in New Tab - -
-
- ) : ( - // For external URLs, use Google Docs viewer -