import { useMemo, useState } from 'react'; import { Database, Search } from 'lucide-react'; import { Badge, Card, CardContent, CardHeader, CardTitle, Input, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, listDatasets, VISIBILITY_LABEL, } from '@ump/shared'; import { useQuery } from '@tanstack/react-query'; /** * Clinical data repository — every imaging dataset on the platform (admin scope=all). * Read-only inventory for milestone 1; per-dataset drill-down lands in a later slice. */ export function DatasetsPage() { const [q, setQ] = useState(''); const { data, isLoading, isError } = useQuery({ queryKey: ['imagehub', 'datasets', 'all'], queryFn: () => listDatasets({ scope: 'all' }), }); const filtered = useMemo(() => { const needle = q.trim().toLowerCase(); if (!needle) return data ?? []; return (data ?? []).filter( (d) => d.name.toLowerCase().includes(needle) || (d.ownerEmail ?? '').toLowerCase().includes(needle) || d.modalityTags.some((t) => t.toLowerCase().includes(needle)), ); }, [data, q]); return (

Kho dữ liệu lâm sàng

Toàn bộ bộ dữ liệu hình ảnh trên hệ thống của các nhà nghiên cứu.

{isLoading ? 'Đang tải…' : `${filtered.length} bộ dữ liệu`}
setQ(e.target.value)} placeholder="Tìm theo tên, chủ sở hữu, nhãn…" className="pl-8" />
{isError &&

Không tải được kho dữ liệu.

} {!isError && !isLoading && filtered.length === 0 && (

Chưa có bộ dữ liệu nào.

)} {filtered.length > 0 && ( Tên bộ dữ liệu Chủ sở hữu Hiển thị Tệp Phiên bản Cập nhật {filtered.map((d) => (
{d.name}
{d.modalityTags.length > 0 && (
{d.modalityTags.map((t) => ( {t} ))}
)}
{d.ownerEmail ?? '—'} {VISIBILITY_LABEL[d.visibility]} {d.fileCount} {d.versionCount} {d.updatedAt ? new Date(d.updatedAt).toLocaleDateString('vi-VN') : '—'}
))}
)}
); }