fix(ui): Fix pagination for documents

#320 fixed
This commit is contained in:
sanwalsulehri 2025-09-19 16:04:22 +05:00
parent b11bec1c65
commit 798cf788f5
24 changed files with 218 additions and 187 deletions

View file

@ -1,6 +1,6 @@
"use client";
import { ChevronDown, ChevronUp, ExternalLink, FileText, Loader2 } from "lucide-react";
import { ChevronDown, ChevronUp, ExternalLink, Loader2 } from "lucide-react";
import type React from "react";
import { useEffect, useRef, useState } from "react";
import { MarkdownViewer } from "@/components/markdown-viewer";

View file

@ -40,10 +40,10 @@ const DocumentSelector = React.memo(
const { search_space_id } = useParams();
const [isOpen, setIsOpen] = useState(false);
const { documents, loading, isLoaded, fetchDocuments } = useDocuments(
Number(search_space_id),
true
);
const { documents, loading, isLoaded, fetchDocuments } = useDocuments(Number(search_space_id), {
lazy: true,
pageSize: 50,
});
const handleOpenChange = useCallback(
(open: boolean) => {

View file

@ -206,14 +206,14 @@ export function DocumentsDataTable({
if (hasChanges && Object.keys(initialRowSelection).length > 0) {
setRowSelection(initialRowSelection);
}
}, [initialRowSelection]);
}, [initialRowSelection, rowSelection]);
// Initialize row selection on mount
useEffect(() => {
if (Object.keys(rowSelection).length === 0 && Object.keys(initialRowSelection).length > 0) {
setRowSelection(initialRowSelection);
}
}, []);
}, [initialRowSelection, rowSelection]);
const filteredDocuments = useMemo(() => {
if (documentTypeFilter === "ALL") return documents;
@ -240,7 +240,7 @@ export function DocumentsDataTable({
const selectedRows = table.getFilteredSelectedRowModel().rows;
const selectedDocuments = selectedRows.map((row) => row.original);
onSelectionChange(selectedDocuments);
}, [rowSelection, onSelectionChange, table]);
}, [onSelectionChange, table]);
const handleClearAll = () => setRowSelection({});

View file

@ -65,7 +65,7 @@ export function AssignRolesStep({ onPreferencesUpdated }: AssignRolesStepProps)
const handleRoleAssignment = async (role: string, configId: string) => {
const newAssignments = {
...assignments,
[role]: configId === "" ? "" : parseInt(configId),
[role]: configId === "" ? "" : parseInt(configId, 10),
};
setAssignments(newAssignments);
@ -80,15 +80,15 @@ export function AssignRolesStep({ onPreferencesUpdated }: AssignRolesStepProps)
const numericAssignments = {
long_context_llm_id:
typeof newAssignments.long_context_llm_id === "string"
? parseInt(newAssignments.long_context_llm_id)
? parseInt(newAssignments.long_context_llm_id, 10)
: newAssignments.long_context_llm_id,
fast_llm_id:
typeof newAssignments.fast_llm_id === "string"
? parseInt(newAssignments.fast_llm_id)
? parseInt(newAssignments.fast_llm_id, 10)
: newAssignments.fast_llm_id,
strategic_llm_id:
typeof newAssignments.strategic_llm_id === "string"
? parseInt(newAssignments.strategic_llm_id)
? parseInt(newAssignments.strategic_llm_id, 10)
: newAssignments.strategic_llm_id,
};

View file

@ -93,7 +93,7 @@ export function LLMRoleManager() {
const handleRoleAssignment = (role: string, configId: string) => {
const newAssignments = {
...assignments,
[role]: configId === "unassigned" ? "" : parseInt(configId),
[role]: configId === "unassigned" ? "" : parseInt(configId, 10),
};
setAssignments(newAssignments);
@ -121,19 +121,19 @@ export function LLMRoleManager() {
long_context_llm_id:
typeof assignments.long_context_llm_id === "string"
? assignments.long_context_llm_id
? parseInt(assignments.long_context_llm_id)
? parseInt(assignments.long_context_llm_id, 10)
: undefined
: assignments.long_context_llm_id,
fast_llm_id:
typeof assignments.fast_llm_id === "string"
? assignments.fast_llm_id
? parseInt(assignments.fast_llm_id)
? parseInt(assignments.fast_llm_id, 10)
: undefined
: assignments.fast_llm_id,
strategic_llm_id:
typeof assignments.strategic_llm_id === "string"
? assignments.strategic_llm_id
? parseInt(assignments.strategic_llm_id)
? parseInt(assignments.strategic_llm_id, 10)
: undefined
: assignments.strategic_llm_id,
};