mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-30 23:26:36 +08:00
### What problem does this PR solve? Feat: Rename agent #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
import { IFlow } from '@/interfaces/database/flow';
|
||||
import flowService from '@/services/flow-service';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { useDebounce } from 'ahooks';
|
||||
import { message } from 'antd';
|
||||
import { useCallback } from 'react';
|
||||
import {
|
||||
useGetPaginationWithRouter,
|
||||
@ -10,6 +11,8 @@ import {
|
||||
|
||||
export const enum AgentApiAction {
|
||||
FetchAgentList = 'fetchAgentList',
|
||||
UpdateAgentSetting = 'updateAgentSetting',
|
||||
DeleteAgent = 'deleteAgent',
|
||||
}
|
||||
|
||||
export const useFetchAgentListByPage = () => {
|
||||
@ -58,3 +61,51 @@ export const useFetchAgentListByPage = () => {
|
||||
setPagination,
|
||||
};
|
||||
};
|
||||
|
||||
export const useUpdateAgentSetting = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const {
|
||||
data,
|
||||
isPending: loading,
|
||||
mutateAsync,
|
||||
} = useMutation({
|
||||
mutationKey: [AgentApiAction.UpdateAgentSetting],
|
||||
mutationFn: async (params: any) => {
|
||||
const ret = await flowService.settingCanvas(params);
|
||||
if (ret?.data?.code === 0) {
|
||||
message.success('success');
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [AgentApiAction.FetchAgentList],
|
||||
});
|
||||
} else {
|
||||
message.error(ret?.data?.data);
|
||||
}
|
||||
return ret?.data?.code;
|
||||
},
|
||||
});
|
||||
|
||||
return { data, loading, updateAgentSetting: mutateAsync };
|
||||
};
|
||||
|
||||
export const useDeleteAgent = () => {
|
||||
const queryClient = useQueryClient();
|
||||
const {
|
||||
data,
|
||||
isPending: loading,
|
||||
mutateAsync,
|
||||
} = useMutation({
|
||||
mutationKey: [AgentApiAction.DeleteAgent],
|
||||
mutationFn: async (canvasIds: string[]) => {
|
||||
const { data } = await flowService.removeCanvas({ canvasIds });
|
||||
if (data.code === 0) {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [AgentApiAction.FetchAgentList],
|
||||
});
|
||||
}
|
||||
return data?.data ?? [];
|
||||
},
|
||||
});
|
||||
|
||||
return { data, loading, deleteAgent: mutateAsync };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user