Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/apis/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

// 플랜 목록 조회
Expand Down
19 changes: 13 additions & 6 deletions src/app/(afterLogin)/[planId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ const PlanPage = () => {
handleNotice(`${data?.userName}님을 초대하였습니다.`, false);
},
onError: (e: AxiosError<ErrorResponse>) => {
const message = e?.response?.data?.error || "";
const message = e?.response?.data?.detail || "";
console.log(e)
handleNotice(message, true);
},
})
Expand All @@ -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<HTMLInputElement>) => {
if (e.key === 'Enter' && email.trim() !== "") {
invitePlan();
}
}

useEffect(() => {
if (!isCollabPending && isCollaborator) {
if (collabError) {
if (!isCollaborator?.isExist) {
handleNotice("존재하지 않는 플랜입니다.", true)
pageAnimateRouter.replace('/')
Expand All @@ -116,7 +124,7 @@ const PlanPage = () => {
pageAnimateRouter.replace('/')
}
}
}, [isCollaborator])
}, [isCollaborator, collabError])

return (
<AnimatePresence>
Expand Down Expand Up @@ -152,7 +160,7 @@ const PlanPage = () => {
placeholder="초대할 상대방 이메일을 입력해주세요"
value={email}
onChange={(e) => setEmail(e.target.value)}
onKeyDown={() => { }} />
onKeyDown={handleEnter} />
<PlaneIcon
className={`${email.trim() !== "" ? `text-point cursor-pointer` : `text-gray-300`}
w-4 transition-all-300-out`}
Expand All @@ -161,7 +169,6 @@ const PlanPage = () => {
</Motion.MotionDiv>
}
</AnimatePresence>

</div>
{user?.email === authorEmail ? (
<Button text={"삭제"} isActive={true} isDelete={true} onClick={deletePlan} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/NoticeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const NoticeModal = () => {
className={`absolute top-0 z-[9999] w-screen h-screen flex items-center justify-center pointer-events-none`}>
<div
className={`
${isAlert ? `text-red-400 border-red-400` : `text-gray-400 border-gray-400`}
${isAlert ? `text-red-400 border-red-400` : `text-point border-point`}
lg:text-[16px] text-[14px] z-[9999] bg-white py-8 px-6 border rounded-[8px] pointer-events-auto select-none`}>
{NoticeModalText}
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Image from "next/image";
import { getUserRequest } from "@/apis/user";
import { AnimatePresence } from "framer-motion";
import useSidebarStore from "@/stores/useSidebarStore";
import { useRouter } from "next/navigation";

const Header = () => {

Expand All @@ -28,6 +29,7 @@ const Header = () => {
setUser,
} = useUserStore();

const router = useRouter();
const pageAnimateRouter = usePageAnimateRouter();

useEffect(() => {
Expand Down Expand Up @@ -81,7 +83,7 @@ const Header = () => {
) : (
<KakaoIcon
className={`lg:w-10 w-8 cursor-pointer`}
onClick={() => pageAnimateRouter.push(`${process.env.NEXT_PUBLIC_DOMAIN}/oauth2/authorization/kakao`)} />
onClick={() => router.push(`${process.env.NEXT_PUBLIC_DOMAIN}/oauth2/authorization/kakao`)} />
))}
</Motion.MotionDiv>
) : (
Expand Down
4 changes: 3 additions & 1 deletion src/components/layout/sidebar/SidebarLogButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { logOutRequest } from "@/apis/user";
import usePageAnimateRouter from "@/hooks/common/usePageAnimateRouter";
import useSidebarStore from "@/stores/useSidebarStore";
import useUserStore from "@/stores/useUserStore";
import { useRouter } from "next/navigation";

interface SidebarLogButtonProps {
isLoggedIn: boolean;
Expand All @@ -19,6 +20,7 @@ const SidebarLogButton = ({
setIsSidebarOpen,
} = useSidebarStore();

const router = useRouter();
const pageAnimateRouter = usePageAnimateRouter();

const logOut = async () => {
Expand All @@ -36,7 +38,7 @@ const SidebarLogButton = ({
className={
`${isLoggedIn ? loginClass : logoutClass}
rounded-[8px] w-full py-2.5 text-[16px] border text-center transition-all-300-out cursor-pointer`}
onClick={isLoggedIn ? logOut : () => pageAnimateRouter.push(`${process.env.NEXT_PUBLIC_DOMAIN}/oauth2/authorization/kakao`)}>
onClick={isLoggedIn ? logOut : () => router.push(`${process.env.NEXT_PUBLIC_DOMAIN}/oauth2/authorization/kakao`)}>
{isLoggedIn ? `로그아웃` : `로그인`}
</div>
)
Expand Down
3 changes: 2 additions & 1 deletion src/components/mypage/PlanList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const PlanList: React.FC<PlanListProps> = ({
queryFn: () => requestQuery.before
? getPlansRequest({ before: requestQuery.before })
: getPlansRequest({ after: requestQuery.after }),
})
},
)

return (
<div
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/plan/usePlanInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const usePlanInfo = (planId: string) => {
const data = docSnapshot.data();

if (data) {
setTitle(data?.title)
setTitle(data?.title)
setAuthorEmail(data?.authorEmail)
setDays(data?.startDate, data?.endDate)
setTags(data?.tags)
Expand Down
12 changes: 6 additions & 6 deletions src/hooks/schedule/useSchedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import usePlanStore from "@/stores/usePlanStore";
export const useSchedule = (planId: string) => {

const {
isSchedulePending: isPending,
setIsSchedulePending: setIsPending,
isSchedulePending,
setIsSchedulePending,
} = usePlanStore();

const [layout, setLayout] = useState<CustomLayout[]>([]);
Expand All @@ -20,7 +20,7 @@ export const useSchedule = (planId: string) => {
const docSnap = await getDoc(targetDoc);

if (!docSnap.exists()) {
setIsPending(true);
setIsSchedulePending(true);
return;
}
}
Expand All @@ -33,13 +33,13 @@ export const useSchedule = (planId: string) => {
const data = docSnapshot.data();
if (data) {
setLayout(data.scheduleList);
setIsPending(false);
setIsSchedulePending(false);
}
});

return () => {
setLayout([]);
setIsPending(true);
setIsSchedulePending(true);
unsubscribe()
};
}, [planId]);
Expand All @@ -52,7 +52,7 @@ export const useSchedule = (planId: string) => {
}, [planId]);

const updateSchedule = (updatedLayout: CustomLayout[]) => {
if (!isPending) {
if (!isSchedulePending) {
throttledUpdateSchedule(updatedLayout);
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/types/error/type.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export interface ErrorResponse {
error: string;
detail: string;
}