Files
ragflow/web/src/hooks/use-agent-request.ts
balibabu 5bb1c383ac Feat: Bind data to the agent module of the home page #3221 (#7385)
### What problem does this PR solve?

Feat: Bind data to the agent module of the home page #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
2025-04-29 09:50:54 +08:00

23 lines
572 B
TypeScript

import { IFlow } from '@/interfaces/database/flow';
import flowService from '@/services/flow-service';
import { useQuery } from '@tanstack/react-query';
export const enum AgentApiAction {
FetchAgentList = 'fetchAgentList',
}
export const useFetchAgentList = () => {
const { data, isFetching: loading } = useQuery<IFlow[]>({
queryKey: [AgentApiAction.FetchAgentList],
initialData: [],
gcTime: 0,
queryFn: async () => {
const { data } = await flowService.listCanvas();
return data?.data ?? [];
},
});
return { data, loading };
};