ConceptPortal-public/rsconcept/frontend/src/features/oss/backend/useFindPredecessor.tsx

16 lines
460 B
TypeScript
Raw Normal View History

2025-02-19 19:26:29 +03:00
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { ossApi } from './api';
export const useFindPredecessor = () => {
2025-02-19 19:26:29 +03:00
const client = useQueryClient();
const mutation = useMutation({
mutationKey: [ossApi.baseKey, 'find-predecessor'],
2025-02-19 19:26:29 +03:00
mutationFn: ossApi.getPredecessor,
onError: () => client.invalidateQueries()
});
return {
findPredecessor: (target: number) => mutation.mutateAsync({ target: target })
};
};