Update standings page to be division name/number agnostic as well
This commit is contained in:
parent
5f1bdbd34f
commit
4973659dd5
@ -13,20 +13,13 @@
|
||||
</div>
|
||||
|
||||
<!-- Division Standings -->
|
||||
<div class="row">
|
||||
<div v-if="standingsByDivision.length && standingsByDivision[0].length" class="row">
|
||||
<template v-for="division in standingsByDivision" :key="division[0].divisionName">
|
||||
<div class="col-md-6">
|
||||
<h3>International wOBA Grand Prix</h3>
|
||||
<StandingsTable :teams="iwgpTeams" :is-divisional=true />
|
||||
<h3>Crabbers</h3>
|
||||
<StandingsTable :teams="balTeams" :is-divisional=true />
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<h3>Fun Diff</h3>
|
||||
<StandingsTable :teams="fdTeams" :is-divisional=true />
|
||||
<h3>NL West</h3>
|
||||
<StandingsTable :teams="nlwTeams" :is-divisional=true />
|
||||
<h3>{{ division[0].divisionName }}</h3>
|
||||
<StandingsTable :teams="division" :is-divisional=true />
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="row">
|
||||
<h3>Wildcard</h3>
|
||||
@ -60,11 +53,8 @@ export default {
|
||||
seasonNumber: CURRENT_SEASON as number,
|
||||
weekNumber: undefined as number | undefined,
|
||||
teamStandings: [] as TeamStanding[],
|
||||
iwgpTeams: [] as TeamStanding[],
|
||||
nlwTeams: [] as TeamStanding[],
|
||||
wildcardTeams: [] as TeamStanding[],
|
||||
balTeams: [] as TeamStanding[],
|
||||
fdTeams: [] as TeamStanding[]
|
||||
standingsByDivision: [[]] as TeamStanding[][]
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@ -76,14 +66,17 @@ export default {
|
||||
this.weekNumber = leagueInfo.week
|
||||
|
||||
this.teamStandings = await fetchStandings(CURRENT_SEASON)
|
||||
// TODO this could be made more robust to division/league structure changes by identifying the unique
|
||||
// league/div abbreviations, then grouping on each into an array of arrays, then in the template above
|
||||
// v-for over the structure to generate a dynamic standings page
|
||||
this.iwgpTeams = this.teamStandings.filter(ts => ts.divisionAbbreviation === 'IWGP')
|
||||
this.nlwTeams = this.teamStandings.filter(ts => ts.divisionAbbreviation === 'NLW')
|
||||
this.balTeams = this.teamStandings.filter(ts => ts.divisionAbbreviation === 'BAL')
|
||||
this.fdTeams = this.teamStandings.filter(ts => ts.divisionAbbreviation === 'FD')
|
||||
this.wildcardTeams = this.teamStandings.filter(ts => ts.isWildcardTeam)
|
||||
|
||||
const teamStandingsByDivisionAbbreviation: { [key: string]: TeamStanding[] } = {}
|
||||
this.teamStandings.forEach(ts => {
|
||||
if (!teamStandingsByDivisionAbbreviation[ts.divisionAbbreviation]) {
|
||||
teamStandingsByDivisionAbbreviation[ts.divisionAbbreviation] = []
|
||||
}
|
||||
teamStandingsByDivisionAbbreviation[ts.divisionAbbreviation].push(ts)
|
||||
})
|
||||
|
||||
this.standingsByDivision = Object.values(teamStandingsByDivisionAbbreviation)
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user