Feat: Filter the knowledge base list using owner #3221 (#7191)

### What problem does this PR solve?

Feat: Filter the knowledge base list using owner #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-04-22 13:44:41 +08:00
committed by GitHub
parent c8194f5fd0
commit 1cc17eb611
12 changed files with 574 additions and 35 deletions

View File

@ -0,0 +1,28 @@
import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks';
import { useMemo } from 'react';
export type OwnerFilterType = {
id: string;
label: string;
count: number;
};
export function useSelectOwners() {
const { list } = useFetchKnowledgeList();
const owners = useMemo(() => {
const ownerList: OwnerFilterType[] = [];
list.forEach((x) => {
const item = ownerList.find((y) => y.id === x.tenant_id);
if (!item) {
ownerList.push({ id: x.tenant_id, label: x.nickname, count: 1 });
} else {
item.count += 1;
}
});
return ownerList;
}, [list]);
return owners;
}