4040 </template >
4141 </VColumn >
4242 <VColumn :header =" $t('Actions')" field =" id" >
43- <template #body >
43+ <template #body = " { item } " >
4444 <div class =" d-flex gap-2" >
45- <button class =" btn btn-danger btn-sm" >
45+ <button class =" btn btn-danger btn-sm" @click = " handleRejectComment(item) " >
4646 <i class =" bi-ban" />
4747 </button >
4848 <button class =" btn btn-success btn-sm z-3" data-bs-toggle =" tooltip" data-bs-placement =" top"
5959 {{ post.title }}
6060 </h1 >
6161 </VModal >
62+ <VModal v-model =" rejectComment.modalIsOpen" ref =" modal" >
63+ <template v-slot :header >
64+ <h1 class =" h6" >Are you sure?</h1 >
65+ </template >
66+ <div >
67+ <h3 class =" text-danger" >Attention</h3 >
68+ <p >
69+ Changed Data can not be restored
70+ </p >
71+ <div >
72+ Post with id ({{ rejectComment?.comment?.id }}) will be rejected!!
73+ </div >
74+ </div >
75+ <template v-slot :footer >
76+ <button class =" btn btn-danger" @click =" handleConfirmRejection($refs.modal.hide)" >
77+ Yes
78+ </button >
79+ <button class =" btn btn-secondary" @click =" $refs.modal.hide()" >
80+ Cancel
81+ </button >
82+ </template >
83+ </VModal >
6284</template >
6385
6486<script >
@@ -70,7 +92,7 @@ import { useFetchComments } from "@/composables/comments.composable";
7092import { useApplyFilters } from " @/composables/filter.composable" ;
7193import useFetchPost from " @/composables/posts.composable" ;
7294import StorageService from " @/services/storage.service" ;
73- import { computed , ref , watch } from " vue" ;
95+ import { computed , reactive , ref , watch } from " vue" ;
7496
7597export default {
7698 name: " CommentsView" ,
@@ -80,6 +102,17 @@ export default {
80102
81103 const { post , postIsLoading , fetchPost } = useFetchPost ();
82104 const postModalIsOpen = ref (false );
105+
106+ const rejectComment = reactive ({
107+ comment: null ,
108+ modalIsOpen: false ,
109+ });
110+
111+ const handleRejectComment = (rejectedComment ) => {
112+ rejectComment .comment = rejectedComment;
113+ rejectComment .modalIsOpen = true ;
114+ };
115+
83116 const handleFetchPost = async (id ) => {
84117 try {
85118 postModalIsOpen .value = true ;
@@ -97,14 +130,18 @@ export default {
97130 email: syncedFilters? .email || undefined ,
98131 });
99132
100- watch (filters, (newFilters ) => {
101- StorageService .set (' synced-filters' ,{... filters,... newFilters})
102- }, { immediate: true })
133+ watch (
134+ filters,
135+ (newFilters ) => {
136+ StorageService .set (" synced-filters" , { ... filters, ... newFilters });
137+ },
138+ { immediate: true }
139+ );
103140
104141 StorageService .observe (" synced-filters" , (newValue ) => {
105142 filters .searchQuery = newValue? .searchQuery || undefined ;
106143 filters .email = newValue? .email || undefined ;
107- filters .status = newValue? .status || undefined
144+ filters .status = newValue? .status || undefined ;
108145 });
109146
110147 const filteredComments = computed (() => {
@@ -131,6 +168,12 @@ export default {
131168 return String (text).replace (regex, " <mark>$1</mark>" );
132169 };
133170
171+ const handleConfirmRejection = () => {
172+ // doing rejection here
173+ rejectComment .comment = null
174+ rejectComment .modalIsOpen = false
175+ }
176+
134177 return {
135178 comments: filteredComments,
136179 commentsIsLoading,
@@ -140,6 +183,9 @@ export default {
140183 postIsLoading,
141184 handleFetchPost,
142185 postModalIsOpen,
186+ handleRejectComment,
187+ handleConfirmRejection,
188+ rejectComment,
143189 };
144190 },
145191 components: {
0 commit comments