suna / frontend /src /hooks /react-query /threads /use-thread-mutations.ts
R-Kentaren's picture
Upload folder using huggingface_hub
4efde5d verified
'use client';
import { createMutationHook } from '@/hooks/use-query';
import {
createThread,
addUserMessage
} from '@/lib/api';
import { toast } from 'sonner';
export const useCreateThread = createMutationHook(
({ projectId }: { projectId: string }) => createThread(projectId),
{
onSuccess: () => {
toast.success('Thread created successfully');
},
errorContext: {
operation: 'create thread',
resource: 'thread'
}
}
);
export const useAddUserMessage = createMutationHook(
({ threadId, content }: { threadId: string; content: string }) =>
addUserMessage(threadId, content),
{
errorContext: {
operation: 'add message',
resource: 'message'
}
}
);