diff --git a/src/pages/ChallengePage.tsx b/src/pages/ChallengePage.tsx index f82f1b6..5b1ed6f 100644 --- a/src/pages/ChallengePage.tsx +++ b/src/pages/ChallengePage.tsx @@ -38,6 +38,7 @@ const ChallengePage = () => { const [endDate, setEndDate] = useState(""); const [isCheered, setIsCheered] = useState(false); const [cheerUpId, setCheerUpId] = useState(""); + const [authorId, setAuthorId] = useState(""); const [show, setShow] = useState(false); const [, , channelId, postId] = window.location.pathname.split("/"); @@ -50,6 +51,7 @@ const ChallengePage = () => { new Date(format(new Date(), "yyyy-MM-dd")), new Date(date) ); + setAuthorId(author._id); validateGuest(author._id); setReward(reward); setCommentCount(comments.length); @@ -115,7 +117,7 @@ const ChallengePage = () => { status === 200 ? setCheerUpYes(data._id) : alert("다시 시도바랍니다."); } } else { - alert("로그인 후 이용가능합니다."); + alert("로그인 후 이용가능합니다!"); } }; @@ -123,7 +125,7 @@ const ChallengePage = () => { const { status } = await fetchPostNotification({ notificationType: "LIKE", notificationTypeId: cheerUpId, - userId: myUser._id, + userId: authorId, }); status === 200 ? console.log("success like-notification") diff --git a/src/pages/CommentPage.tsx b/src/pages/CommentPage.tsx index 3faf5da..a4d0641 100644 --- a/src/pages/CommentPage.tsx +++ b/src/pages/CommentPage.tsx @@ -19,6 +19,7 @@ const CommentPage = () => { const [myUser] = useAtom(userAtom); const [commentList, setCommentList] = useState([]); const [commentValue, setCommentValue] = useState(""); + const [authorId, setAuthorId] = useState(""); const [show, setShow] = useState(false); const [, , , postId] = window.location.pathname.split("/"); @@ -26,7 +27,8 @@ const CommentPage = () => { useEffect(() => { if (Contents?.status === 200) { - const { comments } = Contents?.data; + const { author, comments } = Contents?.data; + setAuthorId(author._id); setCommentList(comments); setShow(true); } @@ -42,7 +44,7 @@ const CommentPage = () => { const { status } = await fetchPostNotification({ notificationType: "COMMENT", notificationTypeId: commentId, - userId: myUser._id, + userId: authorId, }); status === 200 ? console.log("success comment-notification")