diff --git a/frontend/src/vues/CharacterDetails.vue b/frontend/src/vues/CharacterDetails.vue index b154448..3b07fba 100644 --- a/frontend/src/vues/CharacterDetails.vue +++ b/frontend/src/vues/CharacterDetails.vue @@ -8,9 +8,9 @@ Games Played: {{ gamesPlayedCount }} --- Games Applied: {{ gamesAppliedCount }} -- Pick Rate: {{ pickRate.toFixed(2) }}% -
Last Game: {{ new Date(gamesPlayed[gamesPlayed.length - 1].postdate * 1000).toISOString().split('T')[0]}}
- - + + + @@ -26,8 +26,7 @@ const route = useRoute() const characterId = ref(route.params.characterId) const character = ref({}) -const gamesPlayed = ref({}) -const gamesApplied = ref({}) +const games = ref({}) const earnedEB = ref(0) const earnedIP = ref(0) const gamesPlayedCount = ref(0) @@ -42,14 +41,10 @@ async function loadCharacterDetails() { console.log(gameDetails) character.value = characterResponse.data - gamesPlayed.value = gameDetails.data.characterPickedForGame - gamesApplied.value = gameDetails.data.characterAppliedForGame - - calculateDerivedEarnings(gameDetails.data.characterPickedForGame) - calculateDerivedGameStats( - gameDetails.data.characterPickedForGame, - gameDetails.data.characterAppliedForGame - ) + games.value = { + played: gameDetails.data.characterPickedForGame, + applied: gameDetails.data.characterAppliedForGame + } } function calculateDerivedEarnings(gamesPlayedList) { @@ -69,6 +64,11 @@ function calculateDerivedGameStats(gamesPlayedList, gamesAppliedList) { pickRate.value = (gamesPlayedList.length / gamesAppliedList.length) * 100 } +watch(games, (newValue, oldValue) => { + calculateDerivedEarnings(newValue.played) + calculateDerivedGameStats(newValue.played, newValue.applied) +}) + onMounted(async () => { loadCharacterDetails() })