From 67c52c1b41131ef844a64c46f8107448c11e703a Mon Sep 17 00:00:00 2001 From: trungdong11 Date: Tue, 10 Dec 2024 22:05:38 +0700 Subject: [PATCH] [QUIZ-144][QUIZ-167] feat: handle realtime comment --- src/components/group/comment/FormSend.vue | 10 ++++---- src/components/group/comment/ListComment.vue | 20 +++++++++++++--- src/components/group/comment/ListReply.vue | 24 ++++++++++++++----- src/components/layout/sidebar/SidebarMenu.vue | 13 ++++------ src/main.ts | 4 ++++ src/pages/groups/detail/post-detail.vue | 10 ++++---- src/stores/group/post.ts | 10 ++++---- 7 files changed, 58 insertions(+), 33 deletions(-) diff --git a/src/components/group/comment/FormSend.vue b/src/components/group/comment/FormSend.vue index 6caa570..d98aa55 100644 --- a/src/components/group/comment/FormSend.vue +++ b/src/components/group/comment/FormSend.vue @@ -19,8 +19,8 @@ const resetData = () => { } const props = defineProps<{ - refComment?: boolean - idPost: string + focusOnMount?: boolean + postId: string member: any parentId?: string }>() @@ -60,16 +60,16 @@ const onSubmit = async () => { files: listImageUpload, } - await postStore.createCommentPost(props.idPost, data) + await postStore.createCommentPost(props.postId, data) resetData() - // postStore.fetchComments(props.idPost) + // postStore.fetchComments(props.postId) isLoading.value = false } const inputRef = ref() onMounted(() => { - if (props.refComment === true) { + if (props.focusOnMount === true) { inputRef.value.$el.focus() } }) diff --git a/src/components/group/comment/ListComment.vue b/src/components/group/comment/ListComment.vue index 7318339..ed1a95f 100644 --- a/src/components/group/comment/ListComment.vue +++ b/src/components/group/comment/ListComment.vue @@ -6,7 +6,9 @@ import { formatCommentDateTime } from '@/utils/time' import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover' import FormSend from '@/components/group/comment/FormSend.vue' import ListReply from './ListReply.vue' +import { useConfirmDialog } from '@/stores/modal' +const confirmDialog = useConfirmDialog() const postStore = usePostStore() const route = useRoute() @@ -45,6 +47,18 @@ async function onIntersectionObserver([entry]: IntersectionObserverEntry[]) { }, 500) } } + +const handleDeletePost = async (id: string) => { + const result = await confirmDialog.open({ + title: 'Are you want to delete this comment?', + question: 'All data in your comment will be lost', + warning: true, + }) + + if (result.isConfirmed) { + postStore.handleDeleteComment(id) + } +}