diff --git a/src/components/StandingsTable.vue b/src/components/StandingsTable.vue index 3f27872..731db95 100644 --- a/src/components/StandingsTable.vue +++ b/src/components/StandingsTable.vue @@ -37,7 +37,7 @@ import { CURRENT_SEASON } from '@/services/utilities' export default { - name: "StandingsTable", + name: 'StandingsTable', props: { teams: { type: Array, diff --git a/src/services/awardsService.ts b/src/services/awardsService.ts index cd84c3f..24d8344 100644 --- a/src/services/awardsService.ts +++ b/src/services/awardsService.ts @@ -24,3 +24,14 @@ export async function fetchAwardsByPlayerName(playerName: string): Promise { + const response = await fetch(`${SITE_URL}/api/v3/awards?manager_id=${managerId}`) + + const awardsResponse: { + count: number + awards: Award[] + } = await response.json() + + return awardsResponse.awards +} diff --git a/src/services/standingsService.ts b/src/services/standingsService.ts index 0b16eb3..11382f4 100644 --- a/src/services/standingsService.ts +++ b/src/services/standingsService.ts @@ -34,6 +34,7 @@ interface TeamStandingRaw { } export interface TeamStanding { + season: number teamName: string teamAbbreviation: string divisionAbbreviation: string @@ -63,6 +64,26 @@ export async function fetchStandings(seasonNumber: number): Promise { + const response = await fetch(`${SITE_URL}/api/v3/standings?season=${team.season}`) + + const standingsResponse: { + count: number + standings: TeamStandingRaw[] + } = await response.json() + const standings: TeamStandingRaw[] = standingsResponse.standings + + const teamStanding: TeamStandingRaw | undefined = standings.find(ts => ts.team.sname === team.sname) + + if (!teamStanding) { + // throw new Error('standingsService.fetchStandingByTeam - Expected one team standing, found none') + console.warn('standingsService.fetchStandingByTeam - Expected one team standing, found none') + return undefined + } + + return normalizeStanding(teamStanding) +} + function normalizeStanding(standing: TeamStandingRaw): TeamStanding { const totalGamesPlayed = standing.wins + standing.losses // round win percentage to 3 decimal places @@ -72,6 +93,7 @@ function normalizeStanding(standing: TeamStandingRaw): TeamStanding { const isWildcardTeam = standing.wc_gb !== null || standing.wc_e_num !== null return { + season: standing.team.season, teamName: standing.team.sname, teamAbbreviation: standing.team.abbrev, divisionAbbreviation: standing.team.division.division_abbrev, diff --git a/src/services/teamsService.ts b/src/services/teamsService.ts index 2ea44ee..aa1a75e 100644 --- a/src/services/teamsService.ts +++ b/src/services/teamsService.ts @@ -16,6 +16,18 @@ export async function fetchTeam(seasonNumber: number, teamAbbreviation: string): return teamResponse.teams[0] } +export async function fetchTeamsByManagerId(managerId: number): Promise { + const response = await fetch(`${SITE_URL}/api/v3/teams?manager_id=${managerId}`) + + const teamResponse: { + count: number + teams: Team[] + } = await response.json() + + return teamResponse.teams +} + + export async function fetchActiveTeamByOwnerId(ownerId: string): Promise { const response = await fetch(`${SITE_URL}/api/v3/teams?season=${CURRENT_SEASON}&active_only=True&owner_id=${ownerId}`) diff --git a/src/views/ManagerView.vue b/src/views/ManagerView.vue index 4d0d690..5fc9999 100644 --- a/src/views/ManagerView.vue +++ b/src/views/ManagerView.vue @@ -32,128 +32,133 @@

{{ managerName }}

-
🚧 Coming Soon 🚧
- +
+ +

Career Record: {{ managerModel.teamWins }}-{{ managerModel.teamLosses }}

+
- \ No newline at end of file +