Skip to content

Commit

Permalink
Ensure winnings summary appears if there's no entry fee
Browse files Browse the repository at this point in the history
  • Loading branch information
phrasmotica committed Apr 27, 2024
1 parent c6bd0c3 commit 711a373
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/components/results/WinningsSummary.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<script setup lang="ts">
import { computed } from "vue"
import { useI18n } from "vue-i18n"
import WinnerWinnings from "./WinnerWinnings.vue"
import WinningsList from "./WinningsList.vue"
import { useFlyer } from "@/composables/useFlyer"
import { usePlayers } from "@/composables/usePlayers"
import { useFlyerStore } from "@/stores/flyer"
Expand All @@ -13,15 +15,23 @@ const { t } = useI18n()
const flyerStore = useFlyerStore()
const {
mainPhase,
overallStandings,
overallMoneyRecipients,
} = useFlyer(flyerStore.flyer)
const {
getPlayer,
} = usePlayers(mainPhase.value)
const winner = computed(() => getPlayer(overallStandings.value[0].playerId))
</script>

<template>
<div>
<div v-if="overallMoneyRecipients.length > 0" class="m-0 text-center text-xl">
<div class="m-0 text-center text-xl">
<WinnerWinnings
:winner="overallMoneyRecipients[0].player"
:winner="winner"
:winnings="overallMoneyRecipients[0]" />
</div>

Expand Down
4 changes: 4 additions & 0 deletions src/composables/usePlayOffs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ export const usePlayOffs = (f: Flyer | null) => {
const recipients: Winnings[] = []
const remainingPrizeMonies = [...prizeMonies.value]

if (remainingPrizeMonies.length <= 0) {
return recipients
}

let c = 0

for (const s of finalStandings) {
Expand Down
2 changes: 1 addition & 1 deletion src/data/Winnings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import type { Player } from "./Player"

export interface Winnings {
player: Player
amount: number
amount: number | null
colour: string
}
1 change: 0 additions & 1 deletion src/views/ResultsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ const save = () => {
<ResultsMessages />

<div v-if="isFinished" class="mt-1">
<!-- BUG: this doesn't show up if there's no entry fee -->
<WinningsSummary />
</div>
</div>
Expand Down

0 comments on commit 711a373

Please sign in to comment.