대댓글 수정중

This commit is contained in:
kimdaae328 2025-02-20 16:54:37 +09:00
parent 4440946c74
commit fdb2d81e53
4 changed files with 40 additions and 27 deletions

View File

@ -106,28 +106,12 @@ const submitComment = (newComment) => {
// , // ,
const handleUpdateReaction = (reactionData) => { 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', { emit('updateReaction', {
boardId: props.comment.boardId, boardId: props.comment.boardId,
commentId: props.comment.commentId || reactionData.commentId, // reactionData commentId props.comment.commentId commentId: props.comment.commentId || reactionData.commentId,
...reactionData, ...reactionData,
}); });
// console.log('🚀 emit !');
}; };
// //

View File

@ -79,9 +79,7 @@ const isCheck = ref(props.unknown);
const emit = defineEmits(['submitComment']); const emit = defineEmits(['submitComment']);
watch(() => props.unknown, (newVal) => { watch(() => props.unknown, (newVal) => {
if (!newVal) { isCheck.value = newVal;
isCheck.value = false;
}
}); });
function handleCommentSubmit() { function handleCommentSubmit() {

View File

@ -9,6 +9,7 @@
:unknown="unknown" :unknown="unknown"
:comment="comment" :comment="comment"
:isPassword="isPassword" :isPassword="isPassword"
:isEditTextarea="isEditTextarea"
@editClick="editClick" @editClick="editClick"
@deleteClick="deleteClick" @deleteClick="deleteClick"
@submitPassword="submitPassword" @submitPassword="submitPassword"
@ -37,6 +38,10 @@ const props = defineProps({
type: Boolean, type: Boolean,
default: false, default: false,
}, },
isEditTextarea: {
type: Boolean,
default: false,
}
}); });
const emit = defineEmits(['submitComment', 'updateReaction', 'editClick']); const emit = defineEmits(['submitComment', 'updateReaction', 'editClick']);

View File

@ -149,7 +149,7 @@ const authorId = ref(null); // 작성자 id
const isAuthor = computed(() => currentUserId.value === authorId.value); const isAuthor = computed(() => currentUserId.value === authorId.value);
const isEditTextarea = ref({}); const isEditTextarea = ref(false);
const password = ref(''); const password = ref('');
const passwordAlert = ref(""); const passwordAlert = ref("");
@ -257,19 +257,22 @@ const handleCommentReaction = async ({ boardId, commentId, isLike, isDislike })
// //
const fetchComments = async (page = 1) => { const fetchComments = async (page = 1) => {
try { try {
//
const response = await axios.get(`board/${currentBoardId.value}/comments`, { const response = await axios.get(`board/${currentBoardId.value}/comments`, {
params: { params: {
LOCBRDSEQ: currentBoardId.value, LOCBRDSEQ: currentBoardId.value,
page page
} }
}); });
//
const replyResponse = await axios.get(`board/${currentBoardId.value}/reply`, { 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 => ({ comments.value = response.data.data.list.map(comment => ({
commentId: comment.LOCCMTSEQ, // ID commentId: comment.LOCCMTSEQ, // ID
@ -286,8 +289,6 @@ const fetchComments = async (page = 1) => {
children: [] // children: [] //
})); }));
// console.log(" comments.value:", comments.value);
pagination.value = { pagination.value = {
...pagination.value, ...pagination.value,
currentPage: response.data.data.pageNum, // 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 }) => { const handleCommentSubmit = async ({ comment, password }) => {
try { try {