diff --git a/src/components/board/BoardComment.vue b/src/components/board/BoardComment.vue index 4e82bb7..2d0c784 100644 --- a/src/components/board/BoardComment.vue +++ b/src/components/board/BoardComment.vue @@ -124,8 +124,7 @@ const toggleComment = () => { // 부모 컴포넌트에 대댓글 추가 요청 const submitComment = (newComment) => { - console.log(newComment) - emit('submitComment', { parentId: props.comment.commentId, ...newComment, LOCBRDTYP: newComment.LOCBRDTYP }); + emit('submitComment', { parentId: props.comment.commentId, ...newComment }); isComment.value = false; }; diff --git a/src/components/board/BoardCommentArea.vue b/src/components/board/BoardCommentArea.vue index f1a4294..30e9084 100644 --- a/src/components/board/BoardCommentArea.vue +++ b/src/components/board/BoardCommentArea.vue @@ -23,7 +23,7 @@
- +
-
+
@@ -59,7 +60,7 @@ diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index c7a5dcc..1c8b6b2 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -366,17 +366,26 @@ const fetchComments = async (page = 1) => { // const isSubmitting = ref(false); // 댓글 작성 -const handleCommentSubmit = async (data) => { - const { comment, password } = data; - const LOCBRDTYP = data.LOCBRDTYP || null; // undefined 방지 +const handleCommentSubmit = async ({ comment, password }) => { + console.log('댓글') + //비밀번호 입력 안했을시 + // if (!password) { + // passwordAlert.value = "비밀번호를 입력해야 합니다."; + // return; + // } + + // console.log('비밀번호 눌렀음') + + // 중복 실행 방지 + // if (isSubmitting.value) return; + // isSubmitting.value = true; try { const response = await axios.post(`board/${currentBoardId.value}/comment`, { LOCBRDSEQ: currentBoardId.value, LOCCMTRPY: comment, LOCCMTPWD: password, - LOCCMTPNT: 1, - LOCBRDTYP // 익명 여부 전달 + LOCCMTPNT: 1 }); if (response.status === 200) { @@ -390,121 +399,48 @@ const handleCommentSubmit = async (data) => { } }; -// const handleCommentSubmit = async ({ comment, password, LOCBRDTYP }) => { -// console.log('댓글') -// //비밀번호 입력 안했을시 -// // if (!password) { -// // passwordAlert.value = "비밀번호를 입력해야 합니다."; -// // return; -// // } - -// // console.log('비밀번호 눌렀음') - -// // 중복 실행 방지 -// // if (isSubmitting.value) return; -// // isSubmitting.value = true; - -// try { -// // const response = await axios.post(`board/${currentBoardId.value}/comment`, { -// // LOCBRDSEQ: currentBoardId.value, -// // LOCCMTRPY: comment, -// // LOCCMTPWD: password, -// // LOCCMTPNT: 1 -// // }); - -// if (response.status === 200) { -// console.log('댓글 작성 성공:', response.data.message); -// await fetchComments(); -// } else { -// console.log('댓글 작성 실패:', response.data.message); -// } -// } catch (error) { -// console.log('댓글 작성 중 오류 발생:', error); -// } -// }; - // 대댓글 추가 (부모 `BoardCommentList`로부터 이벤트 받아서 처리) const handleCommentReply = async (reply) => { try { - // 익명 여부 체크 (체크박스가 체크되었을 경우 LOCBRDTYP을 300102로 설정) + // console.log('대댓글 작성 요청 데이터:', { + // LOCBRDSEQ: currentBoardId.value, + // LOCCMTRPY: reply.comment, + // LOCCMTPWD: reply.password || null, + // LOCCMTPNT: reply.parentId + // }); - const requestBody = { + const response = await axios.post(`board/${currentBoardId.value}/comment`, { LOCBRDSEQ: currentBoardId.value, LOCCMTRPY: reply.comment, LOCCMTPWD: reply.password || null, - LOCCMTPNT: reply.parentId, - LOCBRDTYP: reply.isCheck ? "300102" : null - }; - console.log(requestBody) - const response = await axios.post(`board/${currentBoardId.value}/comment`, requestBody); + LOCCMTPNT: reply.parentId + }); + + // 응답 데이터를 자세히 로그로 확인 + // console.log('대댓글 작성 응답:', { + // status: response.status, + // data: response.data, + // headers: response.headers + // }); if (response.status === 200) { - if (response.data.code === 200) { - console.log('✅ 대댓글 작성 성공:', response.data); - await fetchComments(); + if (response.data.code === 200) { // 서버 응답 코드도 확인 + console.log('대댓글 작성 성공:', response.data); + await fetchComments(); // 댓글 목록 새로고침 } else { - console.log('❌ 대댓글 작성 실패 - 서버 응답:', response.data); + console.log('대댓글 작성 실패 - 서버 응답:', response.data); alert('대댓글 작성에 실패했습니다.'); } } } catch (error) { - console.error('🚨 대댓글 작성 중 오류 발생:', error); + console.error('대댓글 작성 중 오류 발생:', error); if (error.response) { - console.error('📌 서버 응답 에러:', error.response.data); + console.error('서버 응답 에러:', error.response.data); } - alert('❌ 대댓글 작성 중 오류가 발생했습니다.'); + alert('대댓글 작성 중 오류가 발생했습니다.'); } -}; - -// const handleCommentReply = async (reply) => { -// try { -// // console.log('대댓글 작성 요청 데이터:', { -// // LOCBRDSEQ: currentBoardId.value, -// // LOCCMTRPY: reply.comment, -// // LOCCMTPWD: reply.password || null, -// // LOCCMTPNT: reply.parentId -// // }); - -// // const response = await axios.post(`board/${currentBoardId.value}/comment`, { -// // LOCBRDSEQ: currentBoardId.value, -// // LOCCMTRPY: reply.comment, -// // LOCCMTPWD: reply.password || null, -// // LOCCMTPNT: reply.parentId -// // }); -// const requestBody = { -// LOCBRDSEQ: currentBoardId.value, -// LOCCMTRPY: reply.comment, -// LOCCMTPWD: reply.password || null, -// LOCCMTPNT: reply.parentId, -// LOCBRDTYP -// }; - -// // 응답 데이터를 자세히 로그로 확인 -// // console.log('대댓글 작성 응답:', { -// // status: response.status, -// // data: response.data, -// // headers: response.headers -// // }); - -// const response = await axios.post(`board/${currentBoardId.value}/comment`, requestBody); -// if (response.status === 200) { -// if (response.data.code === 200) { // 서버 응답 코드도 확인 -// console.log('대댓글 작성 성공:', response.data); -// await fetchComments(); // 댓글 목록 새로고침 -// } else { -// console.log('대댓글 작성 실패 - 서버 응답:', response.data); -// alert('대댓글 작성에 실패했습니다.'); -// } -// } -// } catch (error) { -// console.error('대댓글 작성 중 오류 발생:', error); -// if (error.response) { -// console.error('서버 응답 에러:', error.response.data); -// } -// alert('대댓글 작성 중 오류가 발생했습니다.'); -// } -// } +} // 게시글 수정 버튼 클릭 const editClick = (unknown) => {