From 4397c8e1a418c19f4c013b01e33e63b58beccac6 Mon Sep 17 00:00:00 2001 From: cccwon2 Date: Thu, 26 Dec 2024 17:09:48 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=A7=88=EC=9D=B4=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20>=20=EB=82=B4=EA=B0=80=20=EC=93=B4=20=EA=B8=80,=20?= =?UTF-8?q?=EB=82=B4=EA=B0=80=20=EC=93=B4=20=EB=8C=93=EA=B8=80=20=EC=BC=80?= =?UTF-8?q?=EB=B0=A5=20=EB=93=9C=EB=A1=AD=EB=8B=A4=EC=9A=B4=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95=20=EB=93=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(pages)/mypage/page.tsx | 17 ++-- .../components/card/board/BoardComment.tsx | 55 +++++------ .../components/card/board/BoardPostItem.tsx | 93 ++++++++++--------- 3 files changed, 87 insertions(+), 78 deletions(-) diff --git a/src/app/(pages)/mypage/page.tsx b/src/app/(pages)/mypage/page.tsx index f17c7a5b..c8dec036 100644 --- a/src/app/(pages)/mypage/page.tsx +++ b/src/app/(pages)/mypage/page.tsx @@ -6,14 +6,12 @@ import CommentsSection from "./components/sections/CommentsSection"; import ScrapsSection from "./components/sections/ScrapsSection"; import { userRoles } from "@/constants/userRoles"; import { useUser } from "@/hooks/queries/user/me/useUser"; -import toast from "react-hot-toast"; -import { useRouter } from "next/navigation"; +import DotLoadingSpinner from "@/app/components/loading-spinner/DotLoadingSpinner"; export default function MyPage() { const searchParams = useSearchParams(); const currentTab = searchParams.get("tab") || "posts"; - const router = useRouter(); - const { user } = useUser(); + const { user, isLoading } = useUser(); const isApplicant = user?.role === userRoles.APPLICANT; const TabContent = { @@ -22,10 +20,15 @@ export default function MyPage() { ...(isApplicant && { scrap: }), }[currentTab]; - if (!user) { - toast.error("로그인이 필요한 페이지입니다."); - router.push("/login"); + if (isLoading) { + return ( +
+ +
+ ); } + if (!user) return null; + return TabContent; } diff --git a/src/app/components/card/board/BoardComment.tsx b/src/app/components/card/board/BoardComment.tsx index d6c943af..d92640d5 100644 --- a/src/app/components/card/board/BoardComment.tsx +++ b/src/app/components/card/board/BoardComment.tsx @@ -66,37 +66,40 @@ const BoardComment = ({ ]; return ( - -
- {/* Post Section */} -
-
- Icon - {postTitle} +
+ +
+ {/* Post Section */} +
+
+ Icon + {postTitle} +
+

{postContent}

-

{postContent}

-
- {/* Comment Section */} -
-
- {comment} -
-
- {formatLocalDate(updatedAt)} + {/* Comment Section */} +
+
+ {comment} +
+
+ {formatLocalDate(updatedAt)} +
-
- {isAuthor && } -
+ + {/* 케밥 메뉴를 Link 밖으로 이동 */} +
+ {isAuthor && }
- +
); }; diff --git a/src/app/components/card/board/BoardPostItem.tsx b/src/app/components/card/board/BoardPostItem.tsx index 46ee1cea..5fa678c6 100644 --- a/src/app/components/card/board/BoardPostItem.tsx +++ b/src/app/components/card/board/BoardPostItem.tsx @@ -6,7 +6,7 @@ import Link from "next/link"; import KebabDropdown from "../../button/dropdown/KebabDropdown"; import { useRouter } from "next/navigation"; import useModalStore from "@/store/modalStore"; -import { useDeleteComment } from "@/hooks/queries/post/comment/useDeleteComment"; +import { useDeletePost } from "@/hooks/queries/post/useDeletePost"; import { useQueryClient } from "@tanstack/react-query"; const BoardPostItem = ({ @@ -21,7 +21,7 @@ const BoardPostItem = ({ orderBy: string; }) => { const router = useRouter(); - const deleteComment = useDeleteComment(String(post.id)); + const deletePost = useDeletePost(String(post.id)); const queryClient = useQueryClient(); const { openModal, closeModal } = useModalStore(); @@ -33,7 +33,7 @@ const BoardPostItem = ({ confirmText: "삭제하기", cancelText: "취소", onConfirm: () => { - deleteComment.mutate(undefined, { + deletePost.mutate(undefined, { onSuccess: async () => { await queryClient.invalidateQueries({ queryKey: ["post"] }); await queryClient.invalidateQueries({ queryKey: ["myPosts", { limit, orderBy }] }); @@ -59,54 +59,57 @@ const BoardPostItem = ({ ]; return ( - -
-
-

{post.title}

-

{post.content}

-
- - {/* 하단 정보 */} -
-
-
- {post.writer.nickname} - {post.writer.nickname} -
- | - {formatLocalDate(post.updatedAt)} +
+ +
+
+

{post.title}

+

{post.content}

-
-
- 댓글 - {post.commentCount} + + {/* 하단 정보 */} +
+
+
+ {post.writer.nickname} + {post.writer.nickname} +
+ | + {formatLocalDate(post.updatedAt)}
-
- 좋아요 - {post.likeCount} +
+
+ 댓글 + {post.commentCount} +
+
+ 좋아요 + {post.likeCount} +
-
e.stopPropagation()}> - {isAuthor && } -
+ +
+ {isAuthor && }
- +
); }; + export default BoardPostItem;