swap over to using watch for processing loaded games
This commit is contained in:
@@ -8,9 +8,9 @@
|
|||||||
Games Played: {{ gamesPlayedCount }} --- Games Applied: {{ gamesAppliedCount }} -- Pick Rate:
|
Games Played: {{ gamesPlayedCount }} --- Games Applied: {{ gamesAppliedCount }} -- Pick Rate:
|
||||||
{{ pickRate.toFixed(2) }}%
|
{{ pickRate.toFixed(2) }}%
|
||||||
</div>
|
</div>
|
||||||
<div>Last Game: {{ new Date(gamesPlayed[gamesPlayed.length - 1].postdate * 1000).toISOString().split('T')[0]}}</div>
|
<!-- <div>Last Game: {{ new Date(gamesPlayed[gamesPlayed.length - 1].postdate * 1000).toISOString().split('T')[0]}}</div> -->
|
||||||
<GameTable title="Games Played" :gameList="gamesPlayed"></GameTable>
|
<GameTable title="Games Played" :gameList="games.played"></GameTable>
|
||||||
<game-table title="Games Applied" :gameList="gamesApplied"></game-table>
|
<game-table title="Games Applied" :gameList="games.applied"></game-table>
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -26,8 +26,7 @@ const route = useRoute()
|
|||||||
|
|
||||||
const characterId = ref(route.params.characterId)
|
const characterId = ref(route.params.characterId)
|
||||||
const character = ref({})
|
const character = ref({})
|
||||||
const gamesPlayed = ref({})
|
const games = ref({})
|
||||||
const gamesApplied = ref({})
|
|
||||||
const earnedEB = ref(0)
|
const earnedEB = ref(0)
|
||||||
const earnedIP = ref(0)
|
const earnedIP = ref(0)
|
||||||
const gamesPlayedCount = ref(0)
|
const gamesPlayedCount = ref(0)
|
||||||
@@ -42,14 +41,10 @@ async function loadCharacterDetails() {
|
|||||||
console.log(gameDetails)
|
console.log(gameDetails)
|
||||||
|
|
||||||
character.value = characterResponse.data
|
character.value = characterResponse.data
|
||||||
gamesPlayed.value = gameDetails.data.characterPickedForGame
|
games.value = {
|
||||||
gamesApplied.value = gameDetails.data.characterAppliedForGame
|
played: gameDetails.data.characterPickedForGame,
|
||||||
|
applied: gameDetails.data.characterAppliedForGame
|
||||||
calculateDerivedEarnings(gameDetails.data.characterPickedForGame)
|
}
|
||||||
calculateDerivedGameStats(
|
|
||||||
gameDetails.data.characterPickedForGame,
|
|
||||||
gameDetails.data.characterAppliedForGame
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateDerivedEarnings(gamesPlayedList) {
|
function calculateDerivedEarnings(gamesPlayedList) {
|
||||||
@@ -69,6 +64,11 @@ function calculateDerivedGameStats(gamesPlayedList, gamesAppliedList) {
|
|||||||
pickRate.value = (gamesPlayedList.length / gamesAppliedList.length) * 100
|
pickRate.value = (gamesPlayedList.length / gamesAppliedList.length) * 100
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(games, (newValue, oldValue) => {
|
||||||
|
calculateDerivedEarnings(newValue.played)
|
||||||
|
calculateDerivedGameStats(newValue.played, newValue.applied)
|
||||||
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
loadCharacterDetails()
|
loadCharacterDetails()
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user