Portal/rsconcept/frontend/src/features/oss/backend/useFindPredecessor.tsx
2025-02-22 12:20:22 +03:00

16 lines
448 B
TypeScript

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