From 91dcf235763bc1ae04b227485cb27c9420e7a389 Mon Sep 17 00:00:00 2001 From: se0jinYoon Date: Tue, 22 Oct 2024 22:27:09 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=88=98=EC=A0=95=ED=95=98=EA=B8=B0,=20?= =?UTF-8?q?=EC=83=88=EB=A1=9C=EA=B3=A0=EC=B9=A8=20=ED=9B=84=20=EC=95=84?= =?UTF-8?q?=EB=AC=B4=EA=B2=83=EB=8F=84=20=EC=95=88=EA=B3=A0=EC=B9=98?= =?UTF-8?q?=EA=B3=A0=20=EC=A0=9C=EC=B6=9C=ED=95=A0=20=EB=95=8C=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=20=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/postPage/PostPage.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pages/postPage/PostPage.tsx b/src/pages/postPage/PostPage.tsx index 89a5a2d6..4b3f8173 100644 --- a/src/pages/postPage/PostPage.tsx +++ b/src/pages/postPage/PostPage.tsx @@ -323,11 +323,14 @@ const PostPage = () => { }, [type, continueTempPost, tempTitle, tempContent]); const setEditorContent = () => { + // 수정하기 -> 새로고침해서 값이 저장되어 있는 경우 const savedState = localStorage.getItem('editPostState'); + console.log(savedState); if (savedState) { const { content } = JSON.parse(savedState); return content; } else { + // 수정하기 -> 새로고침 안 한 상태일 경우 return location.state.content; } }; @@ -350,12 +353,16 @@ const PostPage = () => { if (contentWithoutTag.trim().length !== 0 && editorVal.title?.trim().length !== 0) { putEditContent(); } - localStorage.removeItem('editPostState'); handleShowModal(); setEditorModalType('editContent'); editorFlowModalDispatch({ type: 'editContent' }); setIgnoreBlocker(true); }; + // 수정하기 모달 확인 + const onClickEditSaveModalBtn = () => { + localStorage.removeItem('editPostState'); + navigate(`/detail/${groupId}/${editPostId}`); + }; // 최초 글 임시 저장 const { mutate: postTempSaveContent } = usePostTempSaveContent({ groupId: groupId, @@ -480,7 +487,7 @@ const PostPage = () => { leftBtnText: '홈으로 가기', leftBtnFn: () => navigate('/'), rightBtnText: '글 확인하기', - rightBtnFn: () => navigate(`/detail/${groupId}/${editPostId}`), + rightBtnFn: onClickEditSaveModalBtn, modalImgType: 'POST', onClickBg: () => {}, };