free agents
This commit is contained in:
20
src/features/tournaments/hooks/use-enroll-free-agent.ts
Normal file
20
src/features/tournaments/hooks/use-enroll-free-agent.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { useServerMutation } from "@/lib/tanstack-query/hooks";
|
||||
import { enrollFreeAgent } from "@/features/tournaments/server";
|
||||
import { tournamentKeys } from "../queries";
|
||||
|
||||
const useEnrollFreeAgent = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useServerMutation({
|
||||
mutationFn: (data: { tournamentId: string, playerId: string, phone: string }) => {
|
||||
return enrollFreeAgent({ data });
|
||||
},
|
||||
onSuccess: (data, { tournamentId }) => {
|
||||
queryClient.invalidateQueries({ queryKey: tournamentKeys.free_agents(tournamentId) });
|
||||
},
|
||||
successMessage: 'You\'ve been added as a free agent!',
|
||||
});
|
||||
};
|
||||
|
||||
export default useEnrollFreeAgent;
|
||||
Reference in New Issue
Block a user