-
Notifications
You must be signed in to change notification settings - Fork 181
/
Copy pathDashboard.vue
127 lines (119 loc) · 4.26 KB
/
Dashboard.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<template>
<PageComponent title="Dashboard">
<div v-if="loading" class="flex justify-center">Loading...</div>
<div
v-else
class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5 text-gray-700"
>
<DashboardCard class="order-1 lg:order-2" style="animation-delay: 0.1s">
<template v-slot:title>Total Surveys</template>
<div
class="text-8xl pb-4 font-semibold flex-1 flex items-center justify-center"
>
{{ data.totalSurveys }}
</div>
</DashboardCard>
<DashboardCard class="order-2 lg:order-4" style="animation-delay: 0.2s">
<template v-slot:title>Total Answers</template>
<div
class="text-8xl pb-4 font-semibold flex-1 flex items-center justify-center"
>
{{ data.totalAnswers }}
</div>
</DashboardCard>
<DashboardCard
class="order-3 lg:order-1 row-span-2"
style="animation-delay: 0.2s"
>
<template v-slot:title>Latest Survey</template>
<div v-if="data.latestSurvey">
<img
:src="data.latestSurvey.image_url"
class="w-[240px] mx-auto"
alt=""
/>
<h3 class="font-bold text-xl mb-3">{{ data.latestSurvey.title }}</h3>
<div class="flex justify-between text-sm mb-1">
<div>Create Date:</div>
<div>{{ data.latestSurvey.created_at }}</div>
</div>
<div class="flex justify-between text-sm mb-1">
<div>Expire Date:</div>
<div>{{ data.latestSurvey.expire_date }}</div>
</div>
<div class="flex justify-between text-sm mb-1">
<div>Status:</div>
<div>{{ data.latestSurvey.status ? "Active" : "Draft" }}</div>
</div>
<div class="flex justify-between text-sm mb-1">
<div>Questions:</div>
<div>{{ data.latestSurvey.questions }}</div>
</div>
<div class="flex justify-between text-sm mb-3">
<div>Answers:</div>
<div>{{ data.latestSurvey.answers }}</div>
</div>
<div class="flex justify-between">
<TButton
:to="{ name: 'SurveyView', params: { id: data.latestSurvey.id } }"
link
>
<PencilIcon class="w-5 h-5 mr-2" />
Edit Survey
</TButton>
<TButton link>
<EyeIcon class="w-5 h-5 mr-2" />
View Answers
</TButton>
</div>
</div>
<div v-else class="text-gray-600 text-center py-16">
Your don't have surveys yet
</div>
</DashboardCard>
<DashboardCard class="order-4 lg:order-3 row-span-2" style="animation-delay: 0.3s">
<template v-slot:title>
<div class="flex justify-between items-center mb-3 px-2">
<h3 class="text-2xl font-semibold">Latest Answers</h3>
<a
href="javascript:void(0)"
class="text-sm text-blue-500 hover:decoration-blue-500"
>
View all
</a>
</div>
</template>
<div v-if="data.latestAnswers.length" class="text-left">
<a
href="#"
v-for="answer of data.latestAnswers"
:key="answer.id"
class="block p-2 hover:bg-gray-100/90"
>
<div class="font-semibold">{{ answer.survey.title }}</div>
<small>
Answer Made at:
<i class="font-semibold">{{ answer.end_date }}</i>
</small>
</a>
</div>
<div v-else class="text-gray-600 text-center py-16">
Your don't have answers yet
</div>
</DashboardCard>
</div>
</PageComponent>
</template>
<script setup>
import {EyeIcon, PencilIcon} from "@heroicons/vue/solid"
import DashboardCard from "../components/core/DashboardCard.vue";
import TButton from "../components/core/TButton.vue";
import PageComponent from "../components/PageComponent.vue";
import { computed } from "vue";
import { useStore } from "vuex";
const store = useStore();
const loading = computed(() => store.state.dashboard.loading);
const data = computed(() => store.state.dashboard.data);
store.dispatch("getDashboardData");
</script>
<style scoped></style>