Skip to content

Commit

Permalink
fix(JoinGuild): close join modal on success
Browse files Browse the repository at this point in the history
  • Loading branch information
BrickheadJohnny committed Dec 12, 2024
1 parent e764e1f commit 5624e27
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/app/(dashboard)/[guildUrlName]/components/JoinGuild.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
useSuspenseQuery,
} from "@tanstack/react-query";
import { EventSourcePlus } from "event-source-plus";
import { useAtom } from "jotai";
import { useAtom, useSetAtom } from "jotai";
import { useParams, useRouter, useSearchParams } from "next/navigation";
import { type ReactNode, useEffect } from "react";
import { toast } from "sonner";
Expand Down Expand Up @@ -168,6 +168,8 @@ const JoinGuildButton = () => {
}),
);

const onJoinModalOpenChange = useSetAtom(joinModalAtom);

const { mutate, isPending } = useMutation({
mutationFn: async () => {
const url = new URL(
Expand Down Expand Up @@ -239,6 +241,7 @@ const JoinGuildButton = () => {
return promise;
},
onSuccess: async (user) => {
onJoinModalOpenChange(false);
queryClient.setQueryData(userOptions().queryKey, user);
},
onError: (error: Error) => {
Expand Down

0 comments on commit 5624e27

Please sign in to comment.