diff --git a/src/components/board/BoardComment.vue b/src/components/board/BoardComment.vue index 9c81151..205d5a6 100644 --- a/src/components/board/BoardComment.vue +++ b/src/components/board/BoardComment.vue @@ -43,7 +43,7 @@ - +
    @@ -63,8 +63,6 @@ :currentPasswordCommentId="currentPasswordCommentId" :passwordCommentAlert="passwordCommentAlert" :password="password" - :commentAlert="commentAlert" - :passwordAlert="passwordAlert" @editClick="handleReplyEditClick" @deleteClick="$emit('deleteClick', child)" @submitEdit="(comment, editedContent) => $emit('submitEdit', comment, editedContent)" @@ -125,12 +123,6 @@ const props = defineProps({ password:{ type: String }, - commentAlert: { - type: String, - }, - passwordAlert: { - type: String, - } }); // emits 정의 diff --git a/src/components/board/BoardCommentList.vue b/src/components/board/BoardCommentList.vue index 667a8ec..1b47923 100644 --- a/src/components/board/BoardCommentList.vue +++ b/src/components/board/BoardCommentList.vue @@ -14,8 +14,6 @@ :passwordCommentAlert="passwordCommentAlert || ''" :currentPasswordCommentId="currentPasswordCommentId" :password="password" - :commentAlert="commentAlert" - :passwordAlert="passwordAlert" @editClick="handleEditClick" @deleteClick="handleDeleteClick" @submitPassword="submitPassword" @@ -65,12 +63,6 @@ const props = defineProps({ password:{ type: String }, - commentAlert: { - type: String, - }, - passwordAlert: { - type: String, - } }); const emit = defineEmits(['submitComment', 'updateReaction', 'editClick', 'deleteClick', 'submitPassword', 'clearPassword','submitEdit', 'update:password']); diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index 7233cce..91c7e29 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -105,8 +105,6 @@ :passwordCommentAlert="passwordCommentAlert" :currentPasswordCommentId="currentPasswordCommentId" :password="password" - :commentAlert="commentAlert" - :passwordAlert="passwordAlert" @editClick="editComment" @deleteClick="deleteComment" @updateReaction="handleCommentReaction" @@ -412,7 +410,7 @@ const handleCommentReply = async (reply) => { }); if (response.status === 200) { - if (response.data.code === 200) { + if (response.data.code === 200) { await fetchComments(); } else { alert('대댓글 작성을 실패했습니다.'); @@ -459,8 +457,12 @@ const findCommentById = (commentId, commentsList) => { return null; }; -// 댓글 수정 버튼 클릭 +// 댓글 수정(대댓글 포함) const editComment = (comment) => { + password.value = ''; + passwordCommentAlert.value = ''; + currentPasswordCommentId.value = null; + const targetComment = findCommentById(comment.commentId, comments.value); if (!targetComment) { @@ -496,12 +498,16 @@ const deleteComment = async (comment) => { } }; -// 익명 비밀번호 창 토글 +// 익명 댓글 비밀번호 창 토글 const toggleCommentPassword = (comment, button) => { if (lastCommentClickedButton.value === button && currentPasswordCommentId.value === comment.commentId) { currentPasswordCommentId.value = null; // 비밀번호 창 닫기 + password.value = ''; + passwordCommentAlert.value = ''; } else { currentPasswordCommentId.value = comment.commentId; // 비밀번호 창 열기 + password.value = ''; + passwordCommentAlert.value = ''; } lastCommentClickedButton.value = button; @@ -557,7 +563,7 @@ const submitPassword = async () => { } }; -// 댓글 삭제 (비밀번호 확인 후) +// 댓글 (비밀번호 확인 후) const submitCommentPassword = async (comment, password) => { if (!password) { passwordCommentAlert.value = "비밀번호를 입력해주세요."; @@ -573,20 +579,25 @@ const submitCommentPassword = async (comment, password) => { }); if (response.data.code === 200 && response.data.data === true) { - passwordCommentAlert.value = ""; + passwordCommentAlert.value = ''; comment.isCommentPassword = false; + // 수정 if (lastCommentClickedButton.value === "edit") { if (targetComment) { + currentPasswordCommentId.value = null; + password.value = ''; + passwordCommentAlert.value = ''; + targetComment.isEditTextarea = true; - passwordCommentAlert.value = ""; } else { alert("수정 취소를 실패했습니다."); } + //삭제 } else if (lastCommentClickedButton.value === "delete") { - passwordCommentAlert.value = ""; + passwordCommentAlert.value = ''; deleteReplyComment(comment) }