Skip to content

Commit 058a793

Browse files
committed
feat(View):Implement comments table & add status field to the data
1 parent 495a0eb commit 058a793

File tree

4 files changed

+74
-4
lines changed

4 files changed

+74
-4
lines changed

src/composables/comments.composable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const useFetchComments = () => {
1515
startLoading();
1616
return CommentsService.getAll(config)
1717
.then((response) => {
18-
comments.value = response.data;
18+
comments.value = response.data.map(item=>({...item,status:"PENDING"}));
1919
return response;
2020
})
2121
.finally(() => {

src/locales/en/messages.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ export default {
55
"Submit": "Submit",
66
"Cancel": "Cancel",
77
"Comments": "Comments",
8+
"Confirm":"Confirm",
9+
"Rejected":"Rejected",
10+
"Pending":"Pending",
811
"Dashboard": "Dashboard",
912
"Users": "Users",
1013
"Authorization Error": "Authorization Error",

src/locales/fa/messages.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export default {
77
"Dashboard": "داشبورد",
88
"Users": "کاربران",
99
"Comments": "نظرات",
10+
"Confirm":"تایید شده",
11+
"Rejected":"رد شده",
12+
"Pending":"در انتظار تایید",
1013
"Authorization Error": "خطای دسترسی",
1114
"No data available": "داده\u200Cای موجود نیست",
1215
"You are successfully logged in": "شما با موفقیت وارد سیستم شدید",

src/views/CommentsView.vue

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,75 @@
11
<template>
22
<div>
3-
<h1>Comments Page</h1>
3+
<div class="h3 mb-4">{{ $t('Comments') }}</div>
4+
<VTableServer :items="comments" :itemsLength="comments.length" :is-loading="commentsIsLoading">
5+
<VColumn :header="$t('Id')" field="id" />
6+
<VColumn :header="$t('Name')" field="name" />
7+
<VColumn :header="$t('Email')" field="email" />
8+
<VColumn :header="$t('Post')" field="postId">
9+
<template #body>
10+
<button class="btn btn-sm btn-outline-info" title="View Related Post">
11+
<i class="bi-eye" />
12+
</button>
13+
</template>
14+
</VColumn>
15+
<VColumn :header="$t('Body')" field="body" />
16+
<VColumn :header="$t('Status')" field="id">
17+
<template #body="{ item }">
18+
<span v-if="item.status==='PENDING'">
19+
{{ $t('Pending') }}
20+
</span>
21+
<span v-if="item.status==='CONFIRMED'">
22+
{{$t('Confirmed')}}
23+
</span>
24+
<span v-if="item.status==='REJECTED'">
25+
{{ $('Rejected') }}
26+
</span>
27+
</template>
28+
</VColumn>
29+
<VColumn :header="$t('Actions')" field="id">
30+
<template #body>
31+
<div class="d-flex gap-2">
32+
<button class="btn btn-danger btn-sm">
33+
<i class="bi-ban" />
34+
</button>
35+
<button class="btn btn-success btn-sm z-3" data-bs-toggle="tooltip" data-bs-placement="top"
36+
data-bs-title="Tooltip on top">
37+
<i class="bi-check-circle" />
38+
</button>
39+
</div>
40+
</template>
41+
</VColumn>
42+
</VTableServer>
443
</div>
544
</template>
645

746
<script>
8-
export default {
9-
name: 'CommentsView'
47+
import VColumn from '@/components/data-table/VColumn.vue';
48+
import VTableServer from '@/components/data-table/VTableServer.vue';
49+
import { useFetchComments } from '@/composables/comments.composable';
50+
import { watch } from 'vue';
51+
52+
export default {
53+
name: 'CommentsView',
54+
setup() {
55+
const { comments, commentsIsLoading, fetchComments } = useFetchComments()
56+
57+
function fetch() {
58+
const config = {}
59+
return fetchComments(config)
60+
}
61+
fetch()
62+
watch([], () => fetchComments())
63+
64+
65+
return {
66+
comments,
67+
commentsIsLoading
68+
}
69+
},
70+
components: {
71+
VTableServer,
72+
VColumn
1073
}
74+
}
1175
</script>

0 commit comments

Comments
 (0)