diff --git a/src/components/board/BoardComment.vue b/src/components/board/BoardComment.vue index a3de641..16916d3 100644 --- a/src/components/board/BoardComment.vue +++ b/src/components/board/BoardComment.vue @@ -106,28 +106,12 @@ const submitComment = (newComment) => { // 좋아요, 싫어요 const handleUpdateReaction = (reactionData) => { - // console.log('📌 BoardComment.vue에서 좋아요 이벤트 발생:', reactionData); - - // if (!reactionData.commentId) { - // console.log("⚠️ reactionData.commentId가 존재하지 않음! 이 값이 null이 되어 덮어씌워질 가능성이 있음."); - // } - - // console.log('🟢 BoardComment.vue의 props.comment:', props.comment); - // console.log('🟢 BoardComment.vue의 commentId:', props.comment.commentId); - - // console.log('🔍 emit 하기 전 reactionData:', { - // boardId: props.comment.boardId, - // commentId: props.comment.commentId, - // ...reactionData - // }); - emit('updateReaction', { boardId: props.comment.boardId, - commentId: props.comment.commentId || reactionData.commentId, // 기존 reactionData에 commentId가 없으면 props.comment.commentId 사용 + commentId: props.comment.commentId || reactionData.commentId, ...reactionData, }); - // console.log('🚀 emit 완료!'); }; // 수정 diff --git a/src/components/board/BoardCommentArea.vue b/src/components/board/BoardCommentArea.vue index 02935d5..a51b939 100644 --- a/src/components/board/BoardCommentArea.vue +++ b/src/components/board/BoardCommentArea.vue @@ -79,9 +79,7 @@ const isCheck = ref(props.unknown); const emit = defineEmits(['submitComment']); watch(() => props.unknown, (newVal) => { - if (!newVal) { - isCheck.value = false; - } + isCheck.value = newVal; }); function handleCommentSubmit() { diff --git a/src/components/board/BoardCommentList.vue b/src/components/board/BoardCommentList.vue index a72b1d8..1ee244a 100644 --- a/src/components/board/BoardCommentList.vue +++ b/src/components/board/BoardCommentList.vue @@ -9,6 +9,7 @@ :unknown="unknown" :comment="comment" :isPassword="isPassword" + :isEditTextarea="isEditTextarea" @editClick="editClick" @deleteClick="deleteClick" @submitPassword="submitPassword" @@ -37,6 +38,10 @@ const props = defineProps({ type: Boolean, default: false, }, + isEditTextarea: { + type: Boolean, + default: false, + } }); const emit = defineEmits(['submitComment', 'updateReaction', 'editClick']); diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index 08dca92..f6c18b2 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -149,7 +149,7 @@ const authorId = ref(null); // 작성자 id const isAuthor = computed(() => currentUserId.value === authorId.value); -const isEditTextarea = ref({}); +const isEditTextarea = ref(false); const password = ref(''); const passwordAlert = ref(""); @@ -257,19 +257,22 @@ const handleCommentReaction = async ({ boardId, commentId, isLike, isDislike }) // 댓글 목록 조회 const fetchComments = async (page = 1) => { try { + // 댓글 const response = await axios.get(`board/${currentBoardId.value}/comments`, { params: { LOCBRDSEQ: currentBoardId.value, page } }); - + + // 대댓글 const replyResponse = await axios.get(`board/${currentBoardId.value}/reply`, { - params: { LOCBRDSEQ: currentBoardId.value } + params: { + LOCCMTPNT: 120 + } }); - // console.log("댓글:", response.data); - console.log("대댓글:", replyResponse.data); + console.log(replyResponse.data) comments.value = response.data.data.list.map(comment => ({ commentId: comment.LOCCMTSEQ, // 댓글 ID @@ -286,8 +289,6 @@ const fetchComments = async (page = 1) => { children: [] // 대댓글을 담을 배열 })); - // console.log("변환 후 comments.value:", comments.value); - pagination.value = { ...pagination.value, currentPage: response.data.data.pageNum, // 현재 페이지 번호 @@ -310,6 +311,31 @@ const fetchComments = async (page = 1) => { } }; +// 대댓글 목록 조회 +// const fetchReplies = async () => { +// try { +// const response = await axios.get(`board/${currentBoardId.value}/reply`); + +// const replyData = response.data.data || []; + +// return replyData.map(reply => ({ +// commentId: reply.LOCCMTSEQ, // 대댓글 ID +// boardId: reply.LOCBRDSEQ, +// parentId: reply.LOCCMTPNT, // 부모 댓글 ID +// content: reply.LOCCMTRPY, +// createdAtRaw: new Date(reply.LOCCMTRDT), // 정렬용 +// createdAt: formattedDate(reply.LOCCMTRDT), // 표시용 +// likeCount: reply.likeCount || 0, +// dislikeCount: reply.dislikeCount || 0, +// likeClicked: false, +// dislikeClicked: false +// })); +// } catch (error) { +// console.error("대댓글 불러오기 오류:", error); +// return []; +// } +// }; + // 댓글 작성 const handleCommentSubmit = async ({ comment, password }) => { try {