File size: 724 Bytes
5da4770 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
'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'
}
}
); |