From d84253bfe0386c39a1109fc00bf242698f08024c Mon Sep 17 00:00:00 2001 From: jjjuni <0210leejun@gmail.com> Date: Tue, 17 Jun 2025 11:27:24 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20style=20=EB=B0=8F=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/plan.ts | 10 +++------- src/app/(afterLogin)/[planId]/page.tsx | 16 +++++++++++----- src/components/common/NoticeModal.tsx | 2 +- src/components/layout/Header.tsx | 4 +++- .../layout/sidebar/SidebarLogButton.tsx | 4 +++- src/components/mypage/PlanList.tsx | 3 ++- src/hooks/plan/usePlanInfo.ts | 2 +- src/hooks/schedule/useSchedule.ts | 12 ++++++------ 8 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/apis/plan.ts b/src/apis/plan.ts index 5b8a346..cd8d5a6 100644 --- a/src/apis/plan.ts +++ b/src/apis/plan.ts @@ -1,3 +1,4 @@ +import { useRouter } from "next/navigation"; import axiosInstance from "./axiosInstance" interface PlanType { @@ -12,13 +13,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..a8ebae5 100644 --- a/src/app/(afterLogin)/[planId]/page.tsx +++ b/src/app/(afterLogin)/[planId]/page.tsx @@ -99,14 +99,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 +123,7 @@ const PlanPage = () => { pageAnimateRouter.replace('/') } } - }, [isCollaborator]) + }, [isCollaborator, collabError]) return ( @@ -152,7 +159,7 @@ const PlanPage = () => { placeholder="초대할 상대방 이메일을 입력해주세요" value={email} onChange={(e) => setEmail(e.target.value)} - onKeyDown={() => { }} /> + onKeyDown={handleEnter} /> { } - {user?.email === authorEmail ? (