mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-30 19:36:25 +02:00
fix type filtering in document table
This commit is contained in:
parent
9c2408d026
commit
644f356430
1 changed files with 15 additions and 3 deletions
|
|
@ -224,6 +224,7 @@ const columns: ColumnDef<Document>[] = [
|
|||
);
|
||||
},
|
||||
size: 180,
|
||||
enableColumnFilter: true,
|
||||
},
|
||||
{
|
||||
header: "Content Summary",
|
||||
|
|
@ -404,25 +405,29 @@ export default function DocumentsTable() {
|
|||
// Get unique status values
|
||||
const uniqueStatusValues = useMemo(() => {
|
||||
const statusColumn = table.getColumn("document_type");
|
||||
if (!data.length) return []; // Don't compute until data is present
|
||||
|
||||
if (!statusColumn) return [];
|
||||
|
||||
const values = Array.from(statusColumn.getFacetedUniqueValues().keys());
|
||||
|
||||
return values.sort();
|
||||
}, [table.getColumn]);
|
||||
}, [table.getColumn, data]);
|
||||
|
||||
// Get counts for each status
|
||||
const statusCounts = useMemo(() => {
|
||||
const statusColumn = table.getColumn("document_type");
|
||||
if (!data.length) return new Map(); // Don't compute until data is present
|
||||
if (!statusColumn) return new Map();
|
||||
return statusColumn.getFacetedUniqueValues();
|
||||
}, [table.getColumn]);
|
||||
}, [table.getColumn, data, columnFilters]);
|
||||
|
||||
const selectedStatuses = useMemo(() => {
|
||||
const filterValue = table.getColumn("document_type")?.getFilterValue() as string[];
|
||||
if (!data.length) return []; // Don't compute until data is present
|
||||
|
||||
return filterValue ?? [];
|
||||
}, [table.getColumn]);
|
||||
}, [table.getColumn, data, columnFilters]);
|
||||
|
||||
const handleStatusChange = (checked: boolean, value: string) => {
|
||||
const filterValue = table.getColumn("document_type")?.getFilterValue() as string[];
|
||||
|
|
@ -437,6 +442,13 @@ export default function DocumentsTable() {
|
|||
}
|
||||
}
|
||||
|
||||
setColumnFilters([
|
||||
{
|
||||
id: "document_type",
|
||||
value: newFilterValue,
|
||||
},
|
||||
]);
|
||||
|
||||
table
|
||||
.getColumn("document_type")
|
||||
?.setFilterValue(newFilterValue.length ? newFilterValue : undefined);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue