diff --git a/app/mission-control/pdf-viewer/page.tsx b/app/mission-control/pdf-viewer/page.tsx index a89e2ef..4679014 100644 --- a/app/mission-control/pdf-viewer/page.tsx +++ b/app/mission-control/pdf-viewer/page.tsx @@ -1,20 +1,155 @@ "use client"; - import BackToMC from "@/components/mission-control/BackToMC"; +import { useState } from "react"; + export default function PdfViewerPage() { + const [pdfUrl, setPdfUrl] = useState(null); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(null); + const [pdfBase64, setPdfBase64] = useState(null); + + 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); + + // Read file as base64 + const reader = new FileReader(); + reader.onload = (event) => { + const base64 = event.target?.result as string; + setPdfBase64(base64); + setPdfUrl(URL.createObjectURL(file)); + 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); + setPdfUrl(input); + setPdfBase64(null); + } catch { + setError("Invalid URL"); + } + setLoading(false); + }; + return ( -
- -
-
-

📰 PDF Viewer

-

Loading...

-
-
-

Loading...

+
+ {/* Header */} +
+

📄 PDF Viewer

+

View and analyze PDF documents

+
+ + {/* Toolbar */} +
+
+ + + + + {pdfUrl && ( + + ↗ Open Original + + )}
+ + {/* Content */} +
+ {error && ( +
+

Error

+

{error}

+ +
+ )} + + {!pdfUrl && !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...

+
+
+ )} + + {pdfUrl && !loading && ( +
+