From 48b6144de6a2d51fdd240d12252e321343ab6d63 Mon Sep 17 00:00:00 2001 From: leejeongho Date: Tue, 27 Aug 2024 01:57:51 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20last-meeting=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/useMeetingMemberService.ts | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/packages/web-domains/src/user/features/get-user-info/services/useMeetingMemberService.ts b/packages/web-domains/src/user/features/get-user-info/services/useMeetingMemberService.ts index 81222f3e..1610bdab 100644 --- a/packages/web-domains/src/user/features/get-user-info/services/useMeetingMemberService.ts +++ b/packages/web-domains/src/user/features/get-user-info/services/useMeetingMemberService.ts @@ -1,23 +1,18 @@ +import { useQueryClient } from '@tanstack/react-query'; import { useRouter } from 'next/navigation'; import { useCreateMeetingMember, Params } from '@/common/apis/queries/useCreateMeetingMember'; +import { useUpdateLastMeeting } from '@/home/common/apis/mutations/useUpdateLastMeeting'; +import { MEETING_INFO_QUERY_KEY } from '@/home/common/apis/queries/useGetMeetingName'; export const useMeetingMemberService = () => { const router = useRouter(); - const { mutateAsync } = useCreateMeetingMember(); + const { mutateAsync: createMeetingMember } = useCreateMeetingMember(); + const { mutateAsync: updateLastMeeting } = useUpdateLastMeeting(); + const queryClient = useQueryClient(); const participateMeeting = async (params: Params) => { - await mutateAsync(params, { - onSuccess: () => { - // 멤버로 가입된 경우 - if (params.role === 'MEMBER') { - router.push(`/user/member/closing?inviteCode=${params.inviteCode}`); - } - // 오너로 가입된 경우 - if (params.role === 'OWNER') { - router.push(`/meeting/new/closing?inviteCode=${params.inviteCode}`); - } - }, + const { data } = await createMeetingMember(params, { onError: (res) => { if (res.response?.status === 404) { alert('모임을 찾을 수 없습니다.'); @@ -27,6 +22,22 @@ export const useMeetingMemberService = () => { } }, }); + await updateLastMeeting( + { meetingId: data.meetingId }, + { + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: [MEETING_INFO_QUERY_KEY] }); + // 멤버로 가입된 경우 + if (params.role === 'MEMBER') { + router.push(`/user/member/closing?inviteCode=${params.inviteCode}`); + } + // 오너로 가입된 경우 + if (params.role === 'OWNER') { + router.push(`/meeting/new/closing?inviteCode=${params.inviteCode}`); + } + }, + }, + ); }; return { participateMeeting }; From 7ff53a8af59abaff798672bbbc5b1796ef19c5b7 Mon Sep 17 00:00:00 2001 From: abg3000 Date: Tue, 27 Aug 2024 22:15:02 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=EC=83=88=20=EB=AA=A8=EC=9E=84=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EC=8B=9C=20=ED=95=B4=EB=8B=B9=20=EB=AA=A8?= =?UTF-8?q?=EC=9E=84=EC=9C=BC=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/home/common/hooks/useSetCurrentMeeting.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/web-domains/src/home/common/hooks/useSetCurrentMeeting.ts b/packages/web-domains/src/home/common/hooks/useSetCurrentMeeting.ts index 762a6ec6..65192436 100644 --- a/packages/web-domains/src/home/common/hooks/useSetCurrentMeeting.ts +++ b/packages/web-domains/src/home/common/hooks/useSetCurrentMeeting.ts @@ -37,6 +37,11 @@ export const useSetCurrentMeeting = () => { } } }; + useEffect(() => { + if (currentMeeting) { + setCurrentMeeting(null); + } + }, []); useEffect(() => { if (!currentMeeting) {