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