add the spinner to the CoachesList

This commit is contained in:
Andreas Zweili 2021-07-28 17:09:10 +02:00
parent 0f04ac7a3e
commit 0317b58706
1 changed files with 11 additions and 5 deletions

View File

@ -6,11 +6,14 @@
<section>
<div class="controls">
<base-button mode="outline" @click="loadCoaches">Refresh</base-button>
<base-button v-if="!isCoach" link to="/register"
<base-button v-if="!isCoach && !isLoading" link to="/register"
>Register as Coach</base-button
>
</div>
<ul v-if="hasCoaches">
<div v-if="isLoading">
<base-spinner></base-spinner>
</div>
<ul v-else-if="hasCoaches">
<coach-item
v-for="coach in filteredCoaches"
:key="coach.id"
@ -34,6 +37,7 @@ export default {
components: { CoachItem, CoachFilter },
data() {
return {
isLoading: false,
activeFilters: {
backend: true,
frontend: true,
@ -61,7 +65,7 @@ export default {
});
},
hasCoaches() {
return this.$store.getters['coaches/hasCoaches'];
return !this.isLoading && this.$store.getters['coaches/hasCoaches'];
}
},
created() {
@ -71,8 +75,10 @@ export default {
setFilter(updatedFilters) {
this.activeFilters = updatedFilters;
},
loadCoaches() {
this.$store.dispatch('coaches/loadCoaches');
async loadCoaches() {
this.isLoading = true;
await this.$store.dispatch('coaches/loadCoaches');
this.isLoading = false;
}
}
};