tahamajs/IE / Projects /front /src /components /publication /PaperObjectPage.tsx
tahamajs's picture
download
raw
4.73 kB
import { useState } from "react";
import { useParams } from "react-router-dom";
import { usePaperObject } from "@/hooks/usePaperObject";
import { PaperHeader } from "./PaperHeader";
import { FigureBrowser } from "./FigureBrowser";
import { TLDROverview } from "./TLDROverview";
import { EngagementMetricsBar } from "./EngagementMetricsBar";
import { AIPreReviewPanel } from "./AIPreReviewPanel";
import { JournalMatchPanel } from "./JournalMatchPanel";
import { PaperQAPanel } from "./PaperQAPanel";
import { PaperAnalyticsDashboard } from "./PaperAnalyticsDashboard";
import { CitationExportPanel } from "./CitationExportPanel";
import { PaperCollectionsPanel } from "./PaperCollectionsPanel";
import { PaperBody } from "./PaperBody"; // ✅ import the correct component
import {
BookOpen, BarChart3, MessageSquare, Download,
Share2, Bookmark, Loader2, AlertTriangle, Sparkles, Send,
PanelLeft,
} from "lucide-react";
const TABS = [
{ key: "paper", icon: BookOpen, label: "Paper" },
{ key: "figures", icon: PanelLeft, label: "Figures" },
{ key: "qa", icon: MessageSquare, label: "Q&A" },
{ key: "analytics", icon: BarChart3, label: "Analytics" },
{ key: "review", icon: Sparkles, label: "AI Review" },
{ key: "journals", icon: Send, label: "Journals" },
{ key: "cite", icon: Download, label: "Cite" },
];
export function PaperObjectPage() {
const { id } = useParams<{ id: string }>();
const { paper, loading, error } = usePaperObject(id!);
const [activeTab, setActiveTab] = useState("paper");
const [showCollections, setShowCollections] = useState(false);
if (loading) {
return (
<div className="flex items-center justify-center min-h-[70vh]">
<Loader2 className="w-8 h-8 animate-spin text-primary" />
</div>
);
}
if (error || !paper) {
return (
<div className="flex flex-col items-center justify-center min-h-[70vh] text-gray-400">
<AlertTriangle className="w-12 h-12 mb-4 text-red-400" />
<p className="text-lg font-medium">{error || "Paper not found"}</p>
</div>
);
}
return (
<div className="max-w-7xl mx-auto px-4 py-8 space-y-6">
<PaperHeader paper={paper} />
<EngagementMetricsBar paper={paper} />
<div className="flex gap-1 border-b border-white/20 dark:border-white/10 overflow-x-auto">
{TABS.map(tab => (
<button
key={tab.key}
onClick={() => setActiveTab(tab.key)}
className={`flex items-center gap-2 px-4 py-2.5 text-sm font-medium rounded-t-xl transition ${
activeTab === tab.key
? "bg-white/30 dark:bg-white/10 text-primary border-b-2 border-primary"
: "text-gray-500 hover:text-gray-700"
}`}
>
<tab.icon className="w-4 h-4" />
<span className="hidden sm:inline">{tab.label}</span>
</button>
))}
<div className="flex-1" />
<button onClick={() => setShowCollections(true)} className="flex items-center gap-1.5 px-4 py-2.5 text-sm text-gray-500 hover:text-primary">
<Bookmark className="w-4 h-4" /> Save
</button>
<button className="flex items-center gap-1.5 px-4 py-2.5 text-sm text-gray-500 hover:text-primary">
<Share2 className="w-4 h-4" /> Share
</button>
</div>
<div className="glass rounded-2xl border border-white/20 dark:border-white/10 p-6">
{activeTab === "paper" && (
<div className="space-y-6">
<TLDROverview tldr={paper.tldr} abstract={paper.abstract} />
<PaperBody body={paper.abstract} /> {/* ✅ uses PaperBody component */}
{/* References and supplementary materials can be added here */}
</div>
)}
{activeTab === "figures" && <FigureBrowser figures={paper.figures} />}
{activeTab === "qa" && <PaperQAPanel paperId={paper.id} paperTitle={paper.title} paperAuthors={paper.authors.map(a => a.fullName)} />}
{activeTab === "analytics" && <PaperAnalyticsDashboard paperId={paper.id} />}
{activeTab === "review" && <AIPreReviewPanel paperId={paper.id} paperTitle={paper.title} />}
{activeTab === "journals" && <JournalMatchPanel paperId={paper.id} abstract={paper.abstract} keywords={paper.keywords} />}
{activeTab === "cite" && <CitationExportPanel paper={paper} />}
</div>
{showCollections && (
<PaperCollectionsPanel
paperId={paper.id}
paperTitle={paper.title}
authors={paper.authors.map(a => a.fullName)}
year={new Date(paper.publishedDate).getFullYear()}
onClose={() => setShowCollections(false)}
/>
)}
</div>
);
}

Xet Storage Details

Size:
4.73 kB
·
Xet hash:
d46541b26f6dd2e2b574a1d60115aef96952ee22d4f56f018ecd9fc4a517115d

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.