import type { KnowledgeEntryWithTags } from "@mosaic/shared";
import { EntryCard } from "./EntryCard";
import { BookOpen } from "lucide-react";
interface EntryListProps {
entries: KnowledgeEntryWithTags[];
isLoading: boolean;
currentPage: number;
totalPages: number;
onPageChange: (page: number) => void;
}
export function EntryList({
entries,
isLoading,
currentPage,
totalPages,
onPageChange,
}: EntryListProps): React.JSX.Element {
if (isLoading) {
return (
);
}
if (entries.length === 0) {
return (
No entries found
Try adjusting your filters or create a new entry
);
}
return (
{/* Entry cards */}
{entries.map((entry) => (
))}
{/* Pagination */}
{totalPages > 1 && (
{Array.from({ length: totalPages }, (_, i) => i + 1).map((page) => {
// Show first, last, current, and pages around current
const shouldShow =
page === 1 || page === totalPages || Math.abs(page - currentPage) <= 1;
// Show ellipsis
const showEllipsisBefore = page === currentPage - 2 && currentPage > 3;
const showEllipsisAfter = page === currentPage + 2 && currentPage < totalPages - 2;
if (!shouldShow && !showEllipsisBefore && !showEllipsisAfter) {
return null;
}
if (showEllipsisBefore || showEllipsisAfter) {
return (
...
);
}
return (
);
})}
)}
{/* Results info */}
Page {currentPage} of {totalPages} ({entries.length} entries)
);
}