mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-08-16 05:40:37 +03:00
21 lines
579 B
TypeScript
21 lines
579 B
TypeScript
![]() |
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||
|
|
||
|
import { promptsApi } from './api';
|
||
|
|
||
|
export function useCreatePromptTemplate() {
|
||
|
const client = useQueryClient();
|
||
|
const mutation = useMutation({
|
||
|
mutationKey: [promptsApi.baseKey, 'create'],
|
||
|
mutationFn: promptsApi.createPromptTemplate,
|
||
|
onSuccess: () => {
|
||
|
void client.invalidateQueries({ queryKey: [promptsApi.baseKey] });
|
||
|
}
|
||
|
});
|
||
|
return {
|
||
|
createPromptTemplate: mutation.mutateAsync,
|
||
|
isPending: mutation.isPending,
|
||
|
error: mutation.error,
|
||
|
reset: mutation.reset
|
||
|
};
|
||
|
}
|