diff --git a/src/apis/plan.ts b/src/apis/plan.ts index 5b8a346..86039a4 100644 --- a/src/apis/plan.ts +++ b/src/apis/plan.ts @@ -12,13 +12,8 @@ interface PlanType { // 플랜 참여 확인 export const isCollaboratorRequest = async (planId: string) => { - try { - const response = await axiosInstance(`/proxy/api/plan/is-collaborator/${planId}`) - return response.data - } catch (e) { - console.log(e) - return null - } + const response = await axiosInstance(`/proxy/api/plan/is-collaborator/${planId}`) + return response.data } // 플랜 목록 조회 diff --git a/src/app/(afterLogin)/[planId]/page.tsx b/src/app/(afterLogin)/[planId]/page.tsx index 38f72e2..fdf79c0 100644 --- a/src/app/(afterLogin)/[planId]/page.tsx +++ b/src/app/(afterLogin)/[planId]/page.tsx @@ -80,7 +80,8 @@ const PlanPage = () => { handleNotice(`${data?.userName}님을 초대하였습니다.`, false); }, onError: (e: AxiosError) => { - const message = e?.response?.data?.error || ""; + const message = e?.response?.data?.detail || ""; + console.log(e) handleNotice(message, true); }, }) @@ -99,14 +100,21 @@ const PlanPage = () => { } }) - const { data: isCollaborator, isPending: isCollabPending } = useQuery({ + const { data: isCollaborator, isPending: isCollabPending, error: collabError } = useQuery({ queryKey: ["isCollaborator", planId], queryFn: async () => isCollaboratorRequest(planId), enabled: !!planId, + retry: 1, }) + const handleEnter = async (e: React.KeyboardEvent) => { + if (e.key === 'Enter' && email.trim() !== "") { + invitePlan(); + } + } + useEffect(() => { - if (!isCollabPending && isCollaborator) { + if (collabError) { if (!isCollaborator?.isExist) { handleNotice("존재하지 않는 플랜입니다.", true) pageAnimateRouter.replace('/') @@ -116,7 +124,7 @@ const PlanPage = () => { pageAnimateRouter.replace('/') } } - }, [isCollaborator]) + }, [isCollaborator, collabError]) return ( @@ -152,7 +160,7 @@ const PlanPage = () => { placeholder="초대할 상대방 이메일을 입력해주세요" value={email} onChange={(e) => setEmail(e.target.value)} - onKeyDown={() => { }} /> + onKeyDown={handleEnter} /> { } - {user?.email === authorEmail ? (