settings link, uneroll team server fn

This commit is contained in:
yohlo
2025-08-24 00:35:38 -05:00
parent 53276cc18e
commit 324e1742f1
9 changed files with 112 additions and 14 deletions

View File

@@ -0,0 +1,30 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { unenrollTeam } from "@/features/tournaments/server";
import toast from '@/lib/sonner';
const useUnenrollTeam = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (data: { tournamentId: string, teamId: string }) => {
return unenrollTeam({ data });
},
onSuccess: (data, { tournamentId }) => {
if (!data) {
toast.error('There was an issue unenrolling. Please try again later.');
} else {
queryClient.invalidateQueries({ queryKey: ['tournaments', 'detail', tournamentId] });
toast.success('Team unenrolled successfully.');
}
},
onError: (error: any) => {
if (error.message) {
toast.error(error.message);
} else {
toast.error('An unexpected error occurred when trying to unenroll the team. Please try again later.');
}
},
});
};
export default useUnenrollTeam;