fixed empty state

This commit is contained in:
Deon Sanchez 2025-09-30 09:45:39 -06:00
parent 52dd723bba
commit bc055319af

View file

@ -55,7 +55,7 @@ function SearchPage() {
const { data = [], isFetching } = useGetSearchQuery(
parsedFilterData?.query || "*",
parsedFilterData,
parsedFilterData
);
const handleTableSearch = (e: ChangeEvent<HTMLInputElement>) => {
@ -63,7 +63,7 @@ function SearchPage() {
};
// Convert TaskFiles to File format and merge with backend results
const taskFilesAsFiles: File[] = taskFiles.map((taskFile) => {
const taskFilesAsFiles: File[] = taskFiles.map(taskFile => {
return {
filename: taskFile.filename,
mimetype: taskFile.mimetype,
@ -76,11 +76,11 @@ function SearchPage() {
const backendFiles = data as File[];
const filteredTaskFiles = taskFilesAsFiles.filter((taskFile) => {
const filteredTaskFiles = taskFilesAsFiles.filter(taskFile => {
return (
taskFile.status !== "active" &&
!backendFiles.some(
(backendFile) => backendFile.filename === taskFile.filename,
backendFile => backendFile.filename === taskFile.filename
)
);
});
@ -106,8 +106,8 @@ function SearchPage() {
onClick={() => {
router.push(
`/knowledge/chunks?filename=${encodeURIComponent(
data?.filename ?? "",
)}`,
data?.filename ?? ""
)}`
);
}}
>
@ -122,7 +122,7 @@ function SearchPage() {
{
field: "size",
headerName: "Size",
valueFormatter: (params) =>
valueFormatter: params =>
params.value ? `${Math.round(params.value / 1024)} KB` : "-",
},
{
@ -132,13 +132,13 @@ function SearchPage() {
{
field: "owner",
headerName: "Owner",
valueFormatter: (params) =>
valueFormatter: params =>
params.data?.owner_name || params.data?.owner_email || "—",
},
{
field: "chunkCount",
headerName: "Chunks",
valueFormatter: (params) => params.data?.chunkCount?.toString() || "-",
valueFormatter: params => params.data?.chunkCount?.toString() || "-",
},
{
field: "avgScore",
@ -200,8 +200,8 @@ function SearchPage() {
try {
// Delete each file individually since the API expects one filename at a time
const deletePromises = selectedRows.map((row) =>
deleteDocumentMutation.mutateAsync({ filename: row.filename }),
const deletePromises = selectedRows.map(row =>
deleteDocumentMutation.mutateAsync({ filename: row.filename })
);
await Promise.all(deletePromises);
@ -209,7 +209,7 @@ function SearchPage() {
toast.success(
`Successfully deleted ${selectedRows.length} document${
selectedRows.length > 1 ? "s" : ""
}`,
}`
);
setSelectedRows([]);
setShowBulkDeleteDialog(false);
@ -222,7 +222,7 @@ function SearchPage() {
toast.error(
error instanceof Error
? error.message
: "Failed to delete some documents",
: "Failed to delete some documents"
);
}
};
@ -313,18 +313,17 @@ function SearchPage() {
rowSelection="multiple"
rowMultiSelectWithClick={false}
suppressRowClickSelection={true}
getRowId={(params) => params.data.filename}
domLayout="autoHeight"
getRowId={params => params.data.filename}
domLayout="normal"
onSelectionChanged={onSelectionChanged}
noRowsOverlayComponent={() => (
<div className="text-center">
<Search className="h-12 w-12 mx-auto mb-4 text-muted-foreground/50" />
<p className="text-lg text-muted-foreground">
No documents found
</p>
<p className="text-sm text-muted-foreground/70 mt-2">
Try adjusting your search terms
</p>
<div className="text-center pb-[45px]">
<div className="text-lg text-primary font-semibold">
No knowledge
</div>
<div className="text-sm mt-1 text-muted-foreground">
Add files from local or your preferred cloud.
</div>
</div>
)}
/>
@ -342,7 +341,7 @@ function SearchPage() {
}? This will remove all chunks and data associated with these documents. This action cannot be undone.
Documents to be deleted:
${selectedRows.map((row) => `${row.filename}`).join("\n")}`}
${selectedRows.map(row => `${row.filename}`).join("\n")}`}
confirmText="Delete All"
onConfirm={handleBulkDelete}
isLoading={deleteDocumentMutation.isPending}