diff --git a/frontend/src/vues/CharacterDetails.vue b/frontend/src/vues/CharacterDetails.vue index 3b07fba..32e6205 100644 --- a/frontend/src/vues/CharacterDetails.vue +++ b/frontend/src/vues/CharacterDetails.vue @@ -8,9 +8,11 @@ Games Played: {{ gamesPlayedCount }} --- Games Applied: {{ gamesAppliedCount }} -- Pick Rate: {{ pickRate.toFixed(2) }}% - +
Last Game: {{ lastPlayedPostDate }}
+
+
@@ -32,14 +34,12 @@ const earnedIP = ref(0) const gamesPlayedCount = ref(0) const gamesAppliedCount = ref(0) const pickRate = ref(0) +const lastPlayedPostDate = ref({}) async function loadCharacterDetails() { const characterResponse = await axios.get(`/api/character/${characterId.value}`) const gameDetails = await axios.post(`/api/character/${characterId.value}/gameHistory`) - console.log(characterResponse) - console.log(gameDetails) - character.value = characterResponse.data games.value = { played: gameDetails.data.characterPickedForGame, @@ -64,7 +64,18 @@ function calculateDerivedGameStats(gamesPlayedList, gamesAppliedList) { pickRate.value = (gamesPlayedList.length / gamesAppliedList.length) * 100 } +function calculateDerivedLastPlayedPostDate(gamesPlayedList) { + if (gamesPlayedList.length === 0) { + lastPlayedPostDate.value = 'N/A' + } else { + lastPlayedPostDate.value = new Date(gamesPlayedList[gamesPlayedList.length - 1].postdate * 1000) + .toISOString() + .split('T')[0] + } +} + watch(games, (newValue, oldValue) => { + calculateDerivedLastPlayedPostDate(newValue.played) calculateDerivedEarnings(newValue.played) calculateDerivedGameStats(newValue.played, newValue.applied) }) diff --git a/frontend/src/vues/GameDetails.vue b/frontend/src/vues/GameDetails.vue index 497c2c6..3822017 100644 --- a/frontend/src/vues/GameDetails.vue +++ b/frontend/src/vues/GameDetails.vue @@ -1,4 +1,3 @@ -