From e41a0c1bf76c39b20acd8618564c8591b6d7e76f Mon Sep 17 00:00:00 2001 From: jizero Date: Sat, 26 Oct 2024 19:23:35 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20boardId=20=EC=A0=80=EC=9E=A5=EA=B0=92?= =?UTF-8?q?=20=EC=88=98=EC=A0=95,=20=EC=88=98=EC=A0=95=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=EC=97=90=20=EC=B9=B4=ED=85=8C=EA=B3=A0=EB=A6=AC=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EB=93=A4=EC=96=B4=EC=98=A4=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95=20#45?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/PostDetail.tsx | 15 ++++++++++----- src/pages/WritePage.tsx | 17 ++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/pages/PostDetail.tsx b/src/pages/PostDetail.tsx index 64f5655..c38c088 100644 --- a/src/pages/PostDetail.tsx +++ b/src/pages/PostDetail.tsx @@ -29,11 +29,12 @@ const PostDetail = () => { const [error, setError] = useState(null) const { sessionId } = useAuthStore() const navigate = useNavigate() + const { userName } = useAuthStore() const handlePostEdit = () => { navigate(`/write?id=${postId}`, { state: { postData } }) } - + console.log(postData) useEffect(() => { const fetchPostData = async () => { try { @@ -77,10 +78,14 @@ const PostDetail = () => { {formatDate(postData.createdAt)} {postData.userNickname} - - - - + {userName === postData.userNickname ? ( + + + + + ) : ( + '' + )} diff --git a/src/pages/WritePage.tsx b/src/pages/WritePage.tsx index acb95d8..ae7953f 100644 --- a/src/pages/WritePage.tsx +++ b/src/pages/WritePage.tsx @@ -145,23 +145,22 @@ const WritePage = () => { } } + useEffect(() => { + if (board) { + setBoardId(Number(board)) + } + }, [board]) + useEffect(() => { if (id && post) { setIsEditing(true) - setTitle(post.title) setContent(post.content) - setCategory(post.category) - setBoard(post.subCategory) + setCategory(post.categoryId) + setBoard(post.boardId) } }, [id, post]) - useEffect(() => { - if (category) { - setBoardId(Number(category)) - } - }, [category]) - return (