2727 </div >
2828 </template >
2929 <div v-if =" surveys.loading" class =" flex justify-center" >Loading...</div >
30- <div v-else >
31- <div class =" grid grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-3" >
30+ <div v-else-if = " surveys.data.length " >
31+ <div class =" grid grid-cols-1 gap-5 sm:grid-cols-2 md:grid-cols-3" >
3232 <SurveyListItem
3333 v-for =" (survey, ind) in surveys.data"
3434 :key =" survey.id"
3535 :survey =" survey"
3636 class =" opacity-0 animate-fade-in-down"
3737 :style =" { animationDelay: `${ind * 0.1}s` }"
38- @delete =" deleteSurvey"
38+ @delete =" deleteSurvey(survey) "
3939 />
4040 </div >
4141 <div class =" flex justify-center mt-5" >
4949 :key =" i"
5050 :disabled =" !link.url"
5151 href =" #"
52- @click =" getForPage(link)"
52+ @click =" getForPage($event, link)"
5353 aria-current =" page"
5454 class =" relative inline-flex items-center px-4 py-2 border text-sm font-medium whitespace-nowrap"
5555 :class =" [
6565 </nav >
6666 </div >
6767 </div >
68+ <div v-else class =" text-gray-600 text-center py-16" >
69+ Your don't have surveys yet
70+ </div >
6871 </PageComponent >
6972</template >
7073
7174<script setup>
7275import store from " ../store" ;
7376import { computed } from " vue" ;
74- import { useRouter } from " vue-router" ;
7577import PageComponent from " ../components/PageComponent.vue" ;
7678import SurveyListItem from " ../components/SurveyListItem.vue" ;
7779
78- const router = useRouter ();
79-
8080const surveys = computed (() => store .state .surveys );
8181
8282store .dispatch (" getSurveys" );
@@ -87,12 +87,14 @@ function deleteSurvey(survey) {
8787 ` Are you sure you want to delete this survey? Operation can't be undone!!`
8888 )
8989 ) {
90- store .dispatch (" deleteSurvey" , survey .id );
90+ store .dispatch (" deleteSurvey" , survey .id ).then (() => {
91+ store .dispatch (" getSurveys" );
92+ });
9193 }
9294}
9395
94- function getForPage (link ) {
95- console . log (link );
96+ function getForPage (ev , link ) {
97+ ev . preventDefault ( );
9698 if (! link .url || link .active ) {
9799 return ;
98100 }
0 commit comments