Fix bug on team view sub-components

This commit is contained in:
Peter 2023-09-21 10:49:16 -04:00
parent 66058ff359
commit 057be7ae00
4 changed files with 25 additions and 2 deletions

View File

@ -135,6 +135,12 @@ export default {
created() {
this.fetchData()
},
watch: {
teamId(newValue, oldValue) {
if (newValue !== oldValue)
this.fetchData()
}
},
methods: {
async fetchData(): Promise<void> {
const unsortedBattingStats: BattingStat[] = await fetchBattingStatsBySeasonAndTeamId(this.seasonNumber, this.teamId, this.isRegularSeason)

View File

@ -88,10 +88,16 @@ export default {
created() {
this.fetchData()
},
watch: {
teamId(newValue, oldValue) {
if (newValue !== oldValue)
this.fetchData()
}
},
methods: {
async fetchData(): Promise<void> {
const unsortedFieldingStats: FieldingStat[] = await fetchFieldingStatsBySeasonAndTeamId(this.seasonNumber, this.teamId, this.isRegularSeason)
this.fieldingStats = unsortedFieldingStats.sort((s1, s2) => POS_MAP[s1.pos] - POS_MAP[s2.pos])
this.fieldingStats = unsortedFieldingStats.sort((s1, s2) => s2.xCheckCount - s1.xCheckCount)
},
formatCaughtStealingPercent(stat: FieldingStat): string {
if (stat.stolenBaseCheckCount === 0 || Number.isNaN(stat.caughtStealingPercent)) {

View File

@ -141,6 +141,12 @@ export default {
created() {
this.fetchData()
},
watch: {
teamId(newValue, oldValue) {
if (newValue !== oldValue)
this.fetchData()
}
},
methods: {
async fetchData(): Promise<void> {
const unsortedPitchingStats: PitchingStat[] = await fetchPitchingStatsBySeasonAndTeamId(this.seasonNumber, this.teamId, this.isRegularSeason)

View File

@ -88,7 +88,6 @@
</table>
</div>
</div>
</div>
</div>
</template>
@ -136,6 +135,12 @@ export default {
created() {
this.fetchData()
},
watch: {
teamId(newValue, oldValue) {
if (newValue !== oldValue)
this.fetchData()
}
},
methods: {
makeScheduleRowsFromGames(games: Game[]): ScheduleRow[] {
const gamesByWeekAndHomeTeam = this.groupByWeekAndHomeTeam(games)