"use client"; import { useEffect, useState } from "react"; import { BookOpen, Bookmark, FileText, Sparkles } from "lucide-react"; import type { ChatMessage, Citation } from "@duoc-thu/shared-types"; import { ChatPanel } from "../_components/ChatPanel"; import { cn } from "@duoc-thu/ui"; export default function TraCuuPage() { const [activePage, setActivePage] = useState(null); const [activeDrug, setActiveDrug] = useState(null); const [pdfSrc, setPdfSrc] = useState("/api/pdf"); const [sessionId, setSessionId] = useState(""); const [messages, setMessages] = useState([]); useEffect(() => { setSessionId(`lookup-${crypto.randomUUID()}`); }, []); function handleCitationClick(citation: Citation) { if (citation.sourcePageRange && citation.sourcePageRange[0]) { // Display the printed page (what's on the paper page, matches the // clinician's physical copy), but navigate the PDF viewer by the // physical page — they diverge by 1-3 pages depending on front-matter // offset, confirmed against the real PDF (physical_page is PyMuPDF's // 0-indexed page; the #page= fragment is 1-indexed). setActivePage(citation.sourcePageRange[0]); setActiveDrug(citation.drugName); setPdfSrc(`/api/pdf#page=${citation.physicalPage + 1}`); } } return (
{/* PDF Document Reader Pane */}
{/* Viewer Header */}
Văn bản gốc: Dược thư quốc gia Việt Nam 2018 (PDF)
{activePage ? (
{activeDrug ? `${activeDrug} — ` : ""}Trang {activePage}
) : (
1.668 trang PDF
)}
{/* Embedded PDF Viewer */}