diff --git a/frontend/src/components/Post/CommentComponent.vue b/frontend/src/components/Post/CommentComponent.vue index 557fac2f..f61f50c1 100644 --- a/frontend/src/components/Post/CommentComponent.vue +++ b/frontend/src/components/Post/CommentComponent.vue @@ -11,23 +11,62 @@

{{ comment.comment }}

- - Posted by {{ comment.user?.username }} - {{ - new Date(comment.createdAt).toLocaleDateString(undefined, { - year: "numeric", - month: "long", - day: "numeric", - }) - }} - at - {{ - new Date(comment.createdAt).toLocaleTimeString(undefined, { - hour: "numeric", - minute: "numeric", - }) - }} - +
+ + Posted by {{ comment.user?.username }} + {{ + new Date(comment.createdAt).toLocaleDateString(undefined, { + year: "numeric", + month: "long", + day: "numeric", + }) + }} + at + {{ + new Date(comment.createdAt).toLocaleTimeString(undefined, { + hour: "numeric", + minute: "numeric", + }) + }} + +
+ +
+
@@ -44,9 +83,26 @@ margin-right: 10px; background-color: #ffc34d; } + +.btn-edit { + background-color: #ffc34d; + color: #fff; + border-radius: 0.25rem; + margin: 3px; +} + +.btn-delete { + background-color: #ff6666; + color: #fff; + border-radius: 0.25rem; + margin: 3px; +} diff --git a/frontend/src/components/PostComponent.vue b/frontend/src/components/PostComponent.vue index ad8bd274..ca8e83d8 100644 --- a/frontend/src/components/PostComponent.vue +++ b/frontend/src/components/PostComponent.vue @@ -116,6 +116,7 @@ v-for="comment in thisPost.comments" :key="comment._id" :id="'comment_' + comment._id" + @comment-deleted="handleCommentDeleted" />
@@ -323,6 +324,14 @@ export default { const options = { year: "numeric", month: "long", day: "numeric" }; return new Date(dateString).toLocaleDateString(undefined, options); }, + handleCommentDeleted(deletedCommentId) { + console.log("Comment Deleted: ", deletedCommentId); + + // Remove the comment with the specified _id from the comments array + this.thisPost.comments = this.thisPost.comments.filter( + (comment) => comment._id !== deletedCommentId + ); + }, }, mounted() { // Check if the post is liked