Skip to content

Commit

Permalink
challenge: show status badge
Browse files Browse the repository at this point in the history
Signed-off-by: smallkirby <ssmallkirby@gmail.com>
  • Loading branch information
smallkirby committed Oct 23, 2023
1 parent d86261f commit 02fd211
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion components/Challenge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<div class="title" @click="onClickTitle">
<span class="title-name">{{challenge.name}}</span>
<span class="points"> {{challenge.value}}pts </span>
<span class="status-badge" v-if="badgeUrl !== null">
<img :src="badgeUrl" />
</span>
</div>
<div class="subtitle">
{{challenge.solves}} solves -
Expand Down Expand Up @@ -128,6 +131,7 @@ export default {
boo: false,
flagText: '',
isSolvesOpen: false,
badgeUrl: null,
};
},
computed: {
Expand All @@ -143,9 +147,10 @@ export default {
return authorTag.value.split(':')[1].trim();
},
},
mounted() {
async mounted() {
if (!this.isStatic) {
this.interval = setInterval(this.updateImgSrc, 60 * 1000);
await this.fetchBadgeUrl();
}
},
destroyed() {
Expand Down Expand Up @@ -258,6 +263,10 @@ export default {
}
}
},
async fetchBadgeUrl() {
const {data} = await this.$axios.get(`/api/v1/challenges/${this.challenge.id}/badge`);
this.badgeUrl = data.badge_url;
},
},
};
</script>
Expand Down

0 comments on commit 02fd211

Please sign in to comment.