Multi-tenant platform (182 pages, 228 API routes, ~30 modules) built on a deterministic verification core: clinical-trial claims checked against ClinicalTrials.gov registered results and raw event counts (ARR/NNT/RR+CI recomputed in code, oracle-tested), code-enforced exact-span grounding, and multi-source cross-verification. Auth/RBAC/multi-tenancy, document processing at scale (unpdf + Docling), agentic workflows, Claude Science connector, compliance/audit, billing, public API, and more. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
92 lines
2.8 KiB
TypeScript
92 lines
2.8 KiB
TypeScript
"use client";
|
|
|
|
import { useCallback, useEffect, useState } from "react";
|
|
import Link from "next/link";
|
|
import { apiGet, type ReferenceLibraryDto } from "./api";
|
|
import { LibraryList } from "./_components/LibraryList";
|
|
import { EmptyCard, ErrorCard } from "./_components/StateCard";
|
|
import { Pagination } from "./_components/Pagination";
|
|
|
|
const PAGE_LIMIT = 20;
|
|
|
|
export default function ReferenceLibrariesPage() {
|
|
const [libraries, setLibraries] = useState<ReferenceLibraryDto[]>([]);
|
|
const [total, setTotal] = useState(0);
|
|
const [page, setPage] = useState(1);
|
|
const [loading, setLoading] = useState(true);
|
|
const [error, setError] = useState<string | null>(null);
|
|
|
|
const load = useCallback(async (p: number) => {
|
|
setLoading(true);
|
|
setError(null);
|
|
const res = await apiGet<ReferenceLibraryDto[]>(
|
|
`/api/reference-libraries?page=${p}&limit=${PAGE_LIMIT}`
|
|
);
|
|
if (!res.success || !res.data) {
|
|
setError(res.error ?? "Failed to load libraries.");
|
|
setLoading(false);
|
|
return;
|
|
}
|
|
setLibraries(res.data);
|
|
setTotal(res.meta?.total ?? res.data.length);
|
|
setLoading(false);
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
void load(page);
|
|
}, [load, page]);
|
|
|
|
const totalPages = Math.max(1, Math.ceil(total / PAGE_LIMIT));
|
|
|
|
return (
|
|
<div>
|
|
<div className="flex items-center justify-between">
|
|
<div>
|
|
<h1 className="text-2xl font-semibold text-ink/80">Reference libraries</h1>
|
|
<p className="mt-1 text-sm text-ink/40">
|
|
Citation collections. Import and export BibTeX, RIS, or CSV.
|
|
</p>
|
|
</div>
|
|
<div className="flex items-center gap-2">
|
|
<Link
|
|
href="/console/references/formats"
|
|
className="text-sm text-ink/60 rounded px-3 py-2 hover:text-ink/80"
|
|
>
|
|
Formats
|
|
</Link>
|
|
<Link
|
|
href="/console/references/new"
|
|
className="text-sm bg-accent text-white rounded px-3 py-2 hover:opacity-90"
|
|
>
|
|
New library
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="mt-6">
|
|
{loading ? (
|
|
<p className="text-sm text-ink/40">Loading libraries...</p>
|
|
) : error ? (
|
|
<ErrorCard message={error} onRetry={() => void load(page)} />
|
|
) : libraries.length === 0 ? (
|
|
<EmptyCard
|
|
title="No reference libraries yet."
|
|
hint="Create your first library to start collecting citations."
|
|
/>
|
|
) : (
|
|
<LibraryList libraries={libraries} />
|
|
)}
|
|
</div>
|
|
|
|
{!loading && !error && total > PAGE_LIMIT ? (
|
|
<Pagination
|
|
page={page}
|
|
totalPages={totalPages}
|
|
onPrev={() => setPage((p) => Math.max(1, p - 1))}
|
|
onNext={() => setPage((p) => Math.min(totalPages, p + 1))}
|
|
/>
|
|
) : null}
|
|
</div>
|
|
);
|
|
}
|