"use client"; import { useState } from "react"; import { KBIndexType } from "@/types"; import { useKBDocuments } from "@/hooks/use-knowledge-base"; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Skeleton } from "@/components/ui/skeleton"; import { KBIndexTypeBadge } from "./kb-index-type-badge"; import { FileCode, FolderOpen, Clock, ChevronLeft, ChevronRight } from "lucide-react"; import { formatDistanceToNow } from "date-fns"; const PAGE_SIZE = 25; interface KBCategoryViewProps { category: KBIndexType | null; } // Inner component that resets when category changes via key function KBCategoryViewInner({ category }: { category: KBIndexType }) { const [page, setPage] = useState(1); const offset = (page - 1) * PAGE_SIZE; const { data, isLoading } = useKBDocuments( category, { limit: PAGE_SIZE, offset }, true ); if (isLoading) { return (
No documents in this category yet.
{doc.source}
Page {page} of {totalPages} ({data?.total} documents)
Select a category from the left to browse indexed documents.