Skip to content

Commit

Permalink
feat: change weekly winner to winners
Browse files Browse the repository at this point in the history
  • Loading branch information
Baiqiang committed Dec 11, 2023
1 parent 59c75dc commit d0ac968
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
16 changes: 5 additions & 11 deletions components/weekly/winner.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
<script setup lang="ts">
const props = defineProps<{
defineProps<{
competition: PastCompetition
}>()
const { locale } = useI18n()
const name = computed(() => {
const matches = props.competition.winner.user.name.match(/^(.+?) \((.+)\)$/)
if (!matches)
return props.competition.winner.user.name
return locale.value === 'en' ? matches[1] : matches[2]
})
</script>

<template>
Expand All @@ -20,8 +12,10 @@ const name = computed(() => {
</h3>
<Icon name="solar:double-alt-arrow-right-linear" size="16" />
</NuxtLink>
<div>
{{ name }} {{ formatResult(competition.winner.average, 2) }} ({{ competition.winner.values.map(v => formatResult(v)).join(', ') }})
<div v-for="winner in competition.winners" :key="winner.id" class="mb-1">
<UserAvatarName :user="winner.user" class="gap-1">
{{ formatResult(winner.average, 2) }} ({{ winner.values.map(v => formatResult(v)).join(', ') }})
</UserAvatarName>
</div>
</div>
</template>
2 changes: 1 addition & 1 deletion utils/competition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface Competition {
}

export interface PastCompetition extends Competition {
winner: Result
winners: Result[]
}
export interface Result {
id: number
Expand Down

0 comments on commit d0ac968

Please sign in to comment.