2025-07-14 15:46:28 +03:00
|
|
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
|
|
|
2025-07-15 20:09:44 +03:00
|
|
|
import { KEYS } from '@/backend/configuration';
|
|
|
|
|
2025-07-14 15:46:28 +03:00
|
|
|
import { promptsApi } from './api';
|
|
|
|
|
|
|
|
export function useDeletePromptTemplate() {
|
|
|
|
const client = useQueryClient();
|
|
|
|
const mutation = useMutation({
|
2025-07-15 20:09:44 +03:00
|
|
|
mutationKey: [KEYS.global_mutation, promptsApi.baseKey, 'delete'],
|
2025-07-14 15:46:28 +03:00
|
|
|
mutationFn: promptsApi.deletePromptTemplate,
|
2025-07-15 20:09:44 +03:00
|
|
|
onSuccess: (_, id) => {
|
2025-07-14 15:46:28 +03:00
|
|
|
void client.invalidateQueries({ queryKey: [promptsApi.baseKey] });
|
|
|
|
void client.invalidateQueries({ queryKey: [promptsApi.baseKey, id] });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return {
|
|
|
|
deletePromptTemplate: mutation.mutateAsync,
|
|
|
|
isPending: mutation.isPending,
|
|
|
|
error: mutation.error,
|
|
|
|
reset: mutation.reset
|
|
|
|
};
|
|
|
|
}
|