AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { FolderDto, UncategorizedFolderId } from '@activepieces/shared';
import { useMutation, useQuery } from '@tanstack/react-query';
import { authenticationSession } from '@/lib/authentication-session';
import { foldersApi } from '../api/folders-api';
export const foldersHooks = {
useFolders: () => {
const folderQuery = useQuery({
queryKey: ['folders', authenticationSession.getProjectId()],
queryFn: () => foldersApi.list(),
});
return {
folders: folderQuery.data,
isLoading: folderQuery.isLoading,
refetch: folderQuery.refetch,
};
},
useFolder: (folderId: string) => {
return useQuery({
queryKey: ['folder', folderId],
queryFn: () => foldersApi.get(folderId),
enabled: folderId !== UncategorizedFolderId,
});
},
};
export const foldersMutations = {
useRenameFolder: ({
onSuccess,
onError,
}: {
onSuccess: () => void;
onError?: (error: unknown) => void;
}) => {
return useMutation({
mutationFn: async ({
folderId,
displayName,
}: {
folderId: string;
displayName: string;
}) => {
return await foldersApi.renameFolder(folderId, { displayName });
},
onSuccess,
onError,
});
},
useCreateFolder: ({
onSuccess,
onError,
}: {
onSuccess: (folder: FolderDto) => void;
onError?: (error: unknown) => void;
}) => {
return useMutation<FolderDto, Error, { displayName: string }>({
mutationFn: async (data) => {
return await foldersApi.create({
displayName: data.displayName.trim(),
projectId: authenticationSession.getProjectId()!,
});
},
onSuccess,
onError,
});
},
};