2025-07-14 15:47:38 +03:00
|
|
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
|
|
|
2025-07-15 21:03:50 +03:00
|
|
|
import { KEYS } from '@/backend/configuration';
|
|
|
|
|
2025-07-14 15:47:38 +03:00
|
|
|
import { promptsApi } from './api';
|
|
|
|
|
|
|
|
export function useCreatePromptTemplate() {
|
|
|
|
const client = useQueryClient();
|
|
|
|
const mutation = useMutation({
|
2025-07-15 21:03:50 +03:00
|
|
|
mutationKey: [KEYS.global_mutation, promptsApi.baseKey, 'create'],
|
2025-07-14 15:47:38 +03:00
|
|
|
mutationFn: promptsApi.createPromptTemplate,
|
|
|
|
onSuccess: () => {
|
|
|
|
void client.invalidateQueries({ queryKey: [promptsApi.baseKey] });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return {
|
|
|
|
createPromptTemplate: mutation.mutateAsync,
|
|
|
|
isPending: mutation.isPending,
|
|
|
|
error: mutation.error,
|
|
|
|
reset: mutation.reset
|
|
|
|
};
|
|
|
|
}
|