Style and partial player page

This commit is contained in:
Peter 2023-08-08 13:32:59 -04:00
parent be2cf17a9e
commit 4bb6aa443c
10 changed files with 291 additions and 106 deletions

BIN
public/sba-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -1,9 +1,9 @@
<template> <template>
<html lang="en" style="height: 100%"> <html lang="en" style="height: 100%">
<!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"> integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootswatch/4.5.2/yeti/bootstrap.min.css"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootswatch/4.5.2/yeti/bootstrap.min.css">
<link rel="stylesheet" href="/src/assets/oldSite.css"> --> <link rel="stylesheet" href="/src/assets/oldSite.css">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">

View File

@ -1,20 +1,195 @@
<template> <template>
<div class="navbar navbar-expand-sm navbar-dark bg-primary "> <nav class="navbar navbar-expand-sm navbar-dark bg-primary" style="margin-bottom: 1rem" id="navbar">
<div class="nav-bar navbar-brand mb-0 h1"> <RouterLink class="nav-link" to="/">SBa Season {{ seasonNumber }}</RouterLink>
<RouterLink to="/">SBa Season {{ seasonNumber }}</RouterLink> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#top-navbar-collapse"
<n-menu mode="horizontal" :options="menuOptions" /> aria-controls="top-navbar-collapse" aria-expanded="false" aria-label="Toggle navigation">
<li class="nav-item"> <a id="login" class="nav-link">Login with Discord</a></li> <span class="navbar-toggler-icon"></span>
<li class="nav-item"> </button>
<a id="team-login-link" href="/teams?abbrev="> <div class="collapse navbar-collapse" id="top-navbar-collapse">
<img id="team-login" style="max-height:35px" hidden /> <ul class="navbar-nav mr-auto">
</a> <li class="nav-item">
</li> <!-- TODO -->
<RouterLink class="nav-link" to="/schedule">Schedule</RouterLink>
</li>
<li class="nav-item">
<!-- TODO -->
<RouterLink class="nav-link" to="/standings">Standings</RouterLink>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="statsDropdown" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">Stats & Leaders</a>
<ul class="dropdown-menu" aria-labelledby="statsDropdown">
<li><a class="dropdown-item dropdown-toggle" href="#">Season Leaders</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/stats/leaders/season?stat=batting">Batting Leaders</a></li>
<li><a class="dropdown-item" href="/stats/leaders/season?stat=pitching">Pitching Leaders</a></li>
<li><a class="dropdown-item" href="/stats/leaders/season?stat=fielding">Fielding Leaders</a></li>
</ul>
</li>
<li><a class="dropdown-item dropdown-toggle" href="#">Team Stats</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/stats/team?stat=batting">Team Batting</a></li>
<li><a class="dropdown-item" href="/stats/team?stat=pitching">Team Pitching</a></li>
<li><a class="dropdown-item" href="/stats/team?stat=fielding">Team Fielding</a></li>
</ul>
</li>
<li><a class="dropdown-item dropdown-toggle" href="#">Single-Game Records</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/stats/leaders/single-game?stat=batting">Single-Game Batting</a></li>
<li><a class="dropdown-item" href="/stats/leaders/single-game?stat=pitching">Single-Game Pitching</a></li>
<li><a class="dropdown-item" href="/stats/leaders/single-game?stat=fielding">Single-Game Fielding</a></li>
</ul>
</li>
<li><a class="dropdown-item dropdown-toggle" href="#">Single-Season Leaders</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/stats/leaders/single-season?stat=batting">Single-Season Batting</a>
</li>
<li><a class="dropdown-item" href="/stats/leaders/single-season?stat=pitching">Single-Season Pitching</a>
</li>
<li><a class="dropdown-item" href="/stats/leaders/single-season?stat=fielding">Single-Season Fielding</a>
</li>
</ul>
</li>
<li><a class="dropdown-item dropdown-toggle" href="#">Career Leaders</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/stats/leaders/career?stat=batting">Career Batting</a></li>
<li><a class="dropdown-item" href="/stats/leaders/career?stat=pitching">Career Pitching</a></li>
<li><a class="dropdown-item" href="/stats/leaders/career?stat=fielding">Career Fielding</a></li>
</ul>
</li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="teamsDropdown" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">Teams</a>
<ul class="dropdown-menu" aria-labelledby="teamsDropdown">
<li><a class="dropdown-item dropdown-toggle" href="#">AL East</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/teams?abbrev=NSH">Gators</a></li>
<li><a class="dropdown-item" href="/teams?abbrev=HAM">Honeybees</a></li>
<li><a class="dropdown-item" href="/teams?abbrev=TK">Kaiju</a></li>
<li><a class="dropdown-item" href="/teams?abbrev=PHP">Phantoms</a></li>
</ul>
</li>
<li><a class="dropdown-item dropdown-toggle" href="#">AL West</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/teams?abbrev=CHC">Cyclones</a></li>
<li><a class="dropdown-item" href="/teams?abbrev=PEI">Mussels</a></li>
<li><a class="dropdown-item" href="/teams?abbrev=WAI">Whale Sharks</a></li>
<li><a class="dropdown-item" href="/teams?abbrev=SHA">Wu Xia</a></li>
</ul>
</li>
<li><a class="dropdown-item dropdown-toggle" href="#">NL East</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/teams?abbrev=DAL">Drillers</a></li>
<li><a class="dropdown-item" href="/teams?abbrev=CLS">Macho Men</a></li>
<li><a class="dropdown-item" href="/teams?abbrev=KSS">Shoebills</a></li>
<li><a class="dropdown-item" href="/teams?abbrev=DEN">Zephyr</a></li>
</ul>
</li>
<li><a class="dropdown-item dropdown-toggle" href="#">NL West</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/teams?abbrev=VA">Angels</a></li>
<li><a class="dropdown-item" href="/teams?abbrev=WV">Black Bears</a></li>
<li><a class="dropdown-item" href="/teams?abbrev=MKE">Bovines</a></li>
<li><a class="dropdown-item" href="/teams?abbrev=BSG">Snow Geese</a></li>
</ul>
</li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="transDropdown" role="button" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">Transactions</a>
<ul class="dropdown-menu" aria-labelledby="transDropdown">
<li><a class="dropdown-item" href="/teams?abbrev=FA">Free Agents</a></li>
<li><a class="dropdown-item" href="/transactions">Transactions</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="historyDropdown" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">History</a>
<ul class="dropdown-menu" aria-labelledby="historyDropdown">
<li><a class="dropdown-item" href="/awards">Awards</a></li>
<li><a class="dropdown-item dropdown-toggle" href="#">Managers</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item dropdown-toggle" href="#">Active</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/managers?name=Basebally">Basebally</a></li>
<li><a class="dropdown-item" href="/managers?name=Brian Taylor">BT</a></li>
<li><a class="dropdown-item" href="/managers?name=Cal">Cal</a></li>
<li><a class="dropdown-item" href="/managers?name=Cash">Cash</a></li>
<li><a class="dropdown-item" href="/managers?name=Derek">Derek</a></li>
<li><a class="dropdown-item" href="/managers?name=Foxx">Foxx</a></li>
<li><a class="dropdown-item" href="/managers?name=Jack">Jack</a></li>
<li><a class="dropdown-item" href="/managers?name=Joe">Joe</a></li>
<li><a class="dropdown-item" href="/managers?name=Josef">Josef</a></li>
<li><a class="dropdown-item" href="/managers?name=JP">JP</a></li>
<li><a class="dropdown-item" href="/managers?name=JZ">JZ</a></li>
<li><a class="dropdown-item" href="/managers?name=Kiger">Kiger</a></li>
<li><a class="dropdown-item" href="/managers?name=Kilo">Kilo</a></li>
<li><a class="dropdown-item" href="/managers?name=Kalin">Kalin</a></li>
<li><a class="dropdown-item" href="/managers?name=Lyle">Lyle</a></li>
<li><a class="dropdown-item" href="/managers?name=Mason">Mason</a></li>
<li><a class="dropdown-item" href="/managers?name=Mcast">Mcast</a></li>
<li><a class="dropdown-item" href="/managers?name=Paulie">Paulie</a></li>
<li><a class="dropdown-item" href="/managers?name=Plack">Plack</a></li>
<li><a class="dropdown-item" href="/managers?name=Reed">Reed</a></li>
<li><a class="dropdown-item" href="/managers?name=Riles">Riles</a></li>
<li><a class="dropdown-item" href="/managers?name=Ryan">Ryan</a></li>
<li><a class="dropdown-item" href="/managers?name=Smitty">Smitty</a></li>
<li><a class="dropdown-item" href="/managers?name=Will">Will</a></li>
</ul>
</li>
<li><a class="dropdown-item dropdown-toggle" href="#">Retired</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/managers?name=Berna">Berna</a></li>
<li><a class="dropdown-item" href="/managers?name=Boof">Boof</a></li>
<li><a class="dropdown-item" href="/managers?name=Caleb">Caleb</a></li>
<li><a class="dropdown-item" href="/managers?name=Diego">Diego</a></li>
<li><a class="dropdown-item" href="/managers?name=Jingles">Jingles</a></li>
<li><a class="dropdown-item" href="/managers?name=Jojo">Jojo</a></li>
<li><a class="dropdown-item" href="/managers?name=Petra">Petra</a></li>
<li><a class="dropdown-item" href="/managers?name=Triumph">Triumph</a></li>
<li><a class="dropdown-item" href="/managers?name=Val">Val</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="dropdown-item dropdown-toggle" href="#">Season Recaps</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/recaps?season=6">Season 6</a></li>
<li><a class="dropdown-item" href="/recaps?season=5">Season 5</a></li>
<li><a class="dropdown-item" href="/recaps?season=4">Season 4</a></li>
<li><a class="dropdown-item" href="/recaps?season=3">Season 3</a></li>
<li><a class="dropdown-item" href="/recaps?season=2">Season 2</a></li>
<li><a class="dropdown-item" href="/recaps?season=1">Season 1</a></li>
</ul>
</li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="/rules">Rules Ref</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/news">News</a>
</li>
<li class="nav-item">
<a id="login" class="nav-link">Login with Discord</a>
</li>
<li class="nav-item">
<!-- TODO RouterLink to team page with team icon -->
<a id="team-login-link" href="/teams?abbrev="></a>
</li>
</ul>
<form class="form-inline" action="/players"> <form class="form-inline" action="/players">
<input type="text" name="name" placeholder="Player Search" list="player-names" id="player-choice"> <input type="text" name="name" placeholder="Player Search" list="player-names" id="player-choice">
<datalist id="player-names"> <datalist id="player-names">
<option v-for="name in playerNames" :value="name">{{ name }}</option> <option v-for="name in playerNames" :value="name">{{ name }}</option>
</datalist> </datalist>
</form> </form>
<ul class="navbar-nav navbar-right"> <ul class="navbar-nav navbar-right">
<li class="nav-item"> <li class="nav-item">
<div class="custom-control custom-switch"> <div class="custom-control custom-switch">
@ -25,7 +200,7 @@
</li> </li>
</ul> </ul>
</div> </div>
</div> </nav>
<!-- <nav class="container"> <!-- <nav class="container">
<RouterLink to="/">SBa Season {{ seasonNumber }}</RouterLink> <RouterLink to="/">SBa Season {{ seasonNumber }}</RouterLink>

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="standings-table"> <div class="standings-table table-responsive-xl">
<table> <table class="table table-sm table-striped">
<thead> <thead class="thead-dark">
<tr> <tr>
<th>Team</th> <th>Team</th>
<th>Record</th> <th>Record</th>

View File

@ -1,16 +0,0 @@
<template>
<button @click="players">Log Players</button>
</template>
<script lang="ts">
import { fetchPlayers } from '@/services/playersService'
import { CURRENT_SEASON } from '@/services/utilities'
export default {
methods: {
async players(): Promise<void> {
await fetchPlayers(CURRENT_SEASON)
}
}
}
</script>

View File

@ -36,8 +36,8 @@ interface TeamStandingRaw {
export interface TeamStanding { export interface TeamStanding {
teamName: string teamName: string
teamAbbreviation: string teamAbbreviation: string
divisionAbbreviation: 'W' | 'E' divisionAbbreviation: string
leagueAbbreviation: 'NL' | 'AL' leagueAbbreviation: string
wins: number wins: number
losses: number losses: number
winPercentage: string, winPercentage: string,
@ -52,7 +52,7 @@ export interface TeamStanding {
} }
export async function fetchStandings(seasonNumber: number): Promise<TeamStanding[]> { export async function fetchStandings(seasonNumber: number): Promise<TeamStanding[]> {
const response = await fetch(`${SITE_URL}/api/v3/standings?season=${seasonNumber}`)//?league_abbrev=AL&division_abbrev=W`) const response = await fetch(`${SITE_URL}/api/v3/standings?season=${seasonNumber}`)
const standingsResponse: { const standingsResponse: {
count: number count: number
@ -66,7 +66,7 @@ export async function fetchStandings(seasonNumber: number): Promise<TeamStanding
function normalizeStanding(standing: TeamStandingRaw): TeamStanding { function normalizeStanding(standing: TeamStandingRaw): TeamStanding {
const totalGamesPlayed = standing.wins + standing.losses const totalGamesPlayed = standing.wins + standing.losses
// round win percentage to 3 decimal places // round win percentage to 3 decimal places
const winPercentage: string = totalGamesPlayed ? `${Math.round(standing.wins / totalGamesPlayed * 1000) / 1000}%` : '-' const winPercentage: string = totalGamesPlayed ? `${(standing.wins / totalGamesPlayed).toFixed(3)}` : '-'
const formattedRunDiff = `${standing.run_diff > 0 ? '+' : ''}${standing.run_diff}` const formattedRunDiff = `${standing.run_diff > 0 ? '+' : ''}${standing.run_diff}`
const isWildcardTeam = standing.wc_gb !== null || standing.wc_e_num !== null const isWildcardTeam = standing.wc_gb !== null || standing.wc_e_num !== null

View File

@ -1,33 +1,37 @@
<template> <template>
<main class="home-view"> <main class="home-view">
<TheWelcome /> <div class="centerDiv">
<div class="row">
<h1>Season {{ seasonNumber }} Standings</h1> <div class="col-sm-12">
<h2 id="week-num">{{ weekNumber ? `Week ${weekNumber}` : '' }}</h2> <h1>Season {{ seasonNumber }} Standings</h1>
</div>
<!-- Division Standings --> </div>
<div class="row"> <div class="row">
<div class="column"> <div class="col-sm-12">
<h2>American League</h2> <h2 id="week-num">{{ weekNumber ? `Week ${weekNumber}` : '' }}</h2>
<h3>East</h3> </div>
<StandingsTable :teams="alEastTeams" :is-divisional=true />
<h3>West</h3>
<StandingsTable :teams="alWestTeams" :is-divisional=true />
<h3>AL Wildcard</h3>
<StandingsTable :teams="alWildcardTeams" :is-divisional=false />
<h2>National League</h2>
<h3>East</h3>
<StandingsTable :teams="nlEastTeams" :is-divisional=true />
<h3>West</h3>
<StandingsTable :teams="nlWestTeams" :is-divisional=true />
<h3>NL Wildcard</h3>
<StandingsTable :teams="nlWildcardTeams" :is-divisional=false />
</div> </div>
<div class="column"> <!-- Division Standings -->
<h3>Latest News</h3> <div class="row">
<div id="news-posts"></div> <div class="col-md-6">
<h2>SBa League</h2>
<h3>International wOBA Grand Prix</h3>
<StandingsTable :teams="iwgpTeams" :is-divisional=true />
<h3>Crabbers</h3>
<StandingsTable :teams="balTeams" :is-divisional=true />
<h3>Fun Diff</h3>
<StandingsTable :teams="fdTeams" :is-divisional=true />
<h3>NL West</h3>
<StandingsTable :teams="nlwTeams" :is-divisional=true />
<h3>Wildcard</h3>
<StandingsTable :teams="wildcardTeams" :is-divisional=false />
</div>
<div class="col-md-6">
<h3>Latest News</h3>
<div id="news-posts"></div>
</div>
</div> </div>
</div> </div>
</main> </main>
@ -38,7 +42,6 @@ import StandingsTable from '@/components/StandingsTable.vue'
import { fetchStandings, type TeamStanding } from '@/services/standingsService' import { fetchStandings, type TeamStanding } from '@/services/standingsService'
import { fetchCurrentLeagueInfo, type LeagueInfo } from '@/services/currentService' import { fetchCurrentLeagueInfo, type LeagueInfo } from '@/services/currentService'
import { CURRENT_SEASON } from '@/services/utilities' import { CURRENT_SEASON } from '@/services/utilities'
import TheWelcome from '../components/TheWelcome.vue'
export default { export default {
name: "HomeView", name: "HomeView",
@ -47,12 +50,11 @@ export default {
seasonNumber: CURRENT_SEASON as number, seasonNumber: CURRENT_SEASON as number,
weekNumber: undefined as number | undefined, weekNumber: undefined as number | undefined,
teamStandings: [] as TeamStanding[], teamStandings: [] as TeamStanding[],
alEastTeams: [] as TeamStanding[], iwgpTeams: [] as TeamStanding[],
alWestTeams: [] as TeamStanding[], nlwTeams: [] as TeamStanding[],
alWildcardTeams: [] as TeamStanding[], wildcardTeams: [] as TeamStanding[],
nlEastTeams: [] as TeamStanding[], balTeams: [] as TeamStanding[],
nlWestTeams: [] as TeamStanding[], fdTeams: [] as TeamStanding[]
nlWildcardTeams: [] as TeamStanding[],
} }
}, },
created() { created() {
@ -63,14 +65,15 @@ export default {
const leagueInfo: LeagueInfo = await fetchCurrentLeagueInfo() const leagueInfo: LeagueInfo = await fetchCurrentLeagueInfo()
this.weekNumber = leagueInfo.week this.weekNumber = leagueInfo.week
// TODO CHANGE THIS this.teamStandings = await fetchStandings(CURRENT_SEASON)
this.teamStandings = await fetchStandings(CURRENT_SEASON - 1) // TODO this could be made more robust to division/league structure changes by identifying the unique
this.alEastTeams = this.teamStandings.filter(ts => ts.divisionAbbreviation === 'E' && ts.leagueAbbreviation === 'AL') // league/div abbreviations, then grouping on each into an array of arrays, then in the template above
this.alWestTeams = this.teamStandings.filter(ts => ts.divisionAbbreviation === 'W' && ts.leagueAbbreviation === 'AL') // v-for over the structure to generate a dynamic standings page
this.nlEastTeams = this.teamStandings.filter(ts => ts.divisionAbbreviation === 'E' && ts.leagueAbbreviation === 'NL') this.iwgpTeams = this.teamStandings.filter(ts => ts.divisionAbbreviation === 'IWGP')
this.nlWestTeams = this.teamStandings.filter(ts => ts.divisionAbbreviation === 'W' && ts.leagueAbbreviation === 'NL') this.nlwTeams = this.teamStandings.filter(ts => ts.divisionAbbreviation === 'NLW')
this.alWildcardTeams = this.teamStandings.filter(ts => ts.leagueAbbreviation === 'AL' && ts.isWildcardTeam) this.balTeams = this.teamStandings.filter(ts => ts.divisionAbbreviation === 'BAL')
this.nlWildcardTeams = this.teamStandings.filter(ts => ts.leagueAbbreviation === 'NL' && ts.isWildcardTeam) this.fdTeams = this.teamStandings.filter(ts => ts.divisionAbbreviation === 'FD')
this.wildcardTeams = this.teamStandings.filter(ts => ts.isWildcardTeam)
}, },
} }

View File

@ -4,7 +4,7 @@
<!-- Heading --> <!-- Heading -->
<div class="row"> <div class="row">
<div class="col-sm"> <div class="col-sm">
<h1 id="player-name">{{ playerName }}</h1> <h1 id="player-name">{{ playerName }}{{ injuryReturnDate }}</h1>
<h2 id="player-wara">{{ player?.wara }} sWAR</h2> <h2 id="player-wara">{{ player?.wara }} sWAR</h2>
</div> </div>
@ -19,25 +19,15 @@
<div class="row"> <div class="row">
<div class="col-sm-auto"> <div class="col-sm-auto">
<img style="max-height:485px; max-width: 100%;" id="team-image" <img style="max-height:485px; max-width: 100%;" id="team-image" :src="playerImageUrl" :alt="playerName">
src="https://cdn.discordapp.com/attachments/953450064985088040/1070303195361984553/PrSBA8r_d.webp" <p><a id="bbref-link" target="_blank" :href="baseballReferenceUrl">Baseball Reference Page</a></p>
alt="Mussels">
<p><a id="bbref-link" target="_blank"
href="https://www.baseball-reference.com/search/search.fcgi?search=Fernando Tatis Jr">Baseball Reference
Page</a></p>
</div> </div>
<div class="col-sm-auto"> <div class="col-sm-auto">
<img style="max-height:485px; max-width: 100%;" id="card-image" <img v-if="playerCardImage1Url" style="max-height:485px; max-width: 100%;" id="card-image"
src="https://sombaseball.ddns.net/cards/2021/fernando-tatis-jr.png"> :src="playerCardImage1Url">
<img id="card2-image" style="max-width:100%"> <img v-if="playerCardImage2Url" style="max-height:485px; max-width: 100%;" id="card-image"
</div> :src="playerCardImage2Url">
</div>
<!-- Injured Block -->
<div class="row" id="injured-block" hidden=false>
<div class="col-sm-12">
<h1 id="injured-return" style="color: red">INJURED - RETURN DATE: </h1>
</div> </div>
</div> </div>
@ -123,7 +113,7 @@
</thead> </thead>
<tbody id="batter-summary-helper"> <tbody id="batter-summary-helper">
<tr> <tr>
<td>3p80</td> <td>{{ injuryRating }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -1210,12 +1200,39 @@ export default {
playerName: { type: String, required: true } playerName: { type: String, required: true }
}, },
computed: { computed: {
isAuthorized(): boolean {
//TODO check discord oauth/cookie/token
return true
},
teamAbbreviation(): string | undefined { teamAbbreviation(): string | undefined {
console.log('abbrev', this.player?.team?.abbrev) console.log('abbrev', this.player?.team?.abbrev)
return this.player?.team?.abbrev return this.player?.team?.abbrev
}, },
teamThumbnail(): string | undefined { teamThumbnail(): string | undefined {
return this.player?.team?.thumbnail return this.player?.team?.thumbnail
},
baseballReferenceUrl(): string | undefined {
if (!this.player?.bbref_id) return undefined
const firstChar = this.player.bbref_id.slice(0, 1)
return `https://www.baseball-reference.com/players/${firstChar}/${this.player.bbref_id}.shtml`
},
playerImageUrl(): string | undefined {
return this.player?.vanity_card ?? this.teamThumbnail
},
playerCardImage1Url(): string | undefined {
if (!this.isAuthorized) return undefined
return this.player?.image
},
playerCardImage2Url(): string | undefined {
if (!this.isAuthorized) return undefined
return this.player?.image2
},
injuryReturnDate(): string | undefined {
if (!this.player?.il_return) return undefined
return ` 🏥 (${this.player.il_return})`
},
injuryRating(): string | undefined {
return this.player?.injury_rating
} }
}, },
created() { created() {

View File

@ -52,7 +52,7 @@
{{ player.name }} {{ player.name }}
</RouterLink> </RouterLink>
</td> </td>
<td>{{ player.wara }}</td> <td>{{ player.wara.toFixed(2) }}</td>
<td>{{ player.injury_rating }}</td> <td>{{ player.injury_rating }}</td>
<td>{{ allPositions(player) }}</td> <td>{{ allPositions(player) }}</td>
</tr> </tr>
@ -80,7 +80,7 @@
<tr> <tr>
<th>Pos</th> <th>Pos</th>
<th>Name</th> <th>Name</th>
<th>WARa</th> <th>sWAR</th>
<th>Inj Return</th> <th>Inj Return</th>
<th>Positions</th> <th>Positions</th>
</tr> </tr>
@ -93,7 +93,7 @@
{{ player.name }} {{ player.name }}
</RouterLink> </RouterLink>
</td> </td>
<td>{{ player.wara }}</td> <td>{{ player.wara.toFixed(2) }}</td>
<td>{{ player.il_return }}</td> <td>{{ player.il_return }}</td>
<td>{{ allPositions(player) }}</td> <td>{{ allPositions(player) }}</td>
</tr> </tr>
@ -107,7 +107,7 @@
<tr> <tr>
<th>Pos</th> <th>Pos</th>
<th>Name</th> <th>Name</th>
<th>WARa</th> <th>sWAR</th>
<th>Inj Return</th> <th>Inj Return</th>
<th>Positions</th> <th>Positions</th>
</tr> </tr>
@ -120,7 +120,7 @@
{{ player.name }} {{ player.name }}
</RouterLink> </RouterLink>
</td> </td>
<td>{{ player.wara }}</td> <td>{{ player.wara.toFixed(2) }}</td>
<td>{{ player.il_return }}</td> <td>{{ player.il_return }}</td>
<td>{{ allPositions(player) }}</td> <td>{{ allPositions(player) }}</td>
</tr> </tr>
@ -237,7 +237,7 @@ export default {
this.teamMinors = await fetchTeam(this.seasonNumber, `${this.teamAbbreviation}MiL`) this.teamMinors = await fetchTeam(this.seasonNumber, `${this.teamAbbreviation}MiL`)
this.teamInjuredList = await fetchTeam(this.seasonNumber, `${this.teamAbbreviation}IL`) this.teamInjuredList = await fetchTeam(this.seasonNumber, `${this.teamAbbreviation}IL`)
this.teamStanding = (await fetchStandings(this.seasonNumber - 1)).find(ts => ts.teamName === this.team?.sname) this.teamStanding = (await fetchStandings(this.seasonNumber)).find(ts => ts.teamName === this.team?.sname)
this.weekNumber = (await fetchCurrentLeagueInfo()).week this.weekNumber = (await fetchCurrentLeagueInfo()).week
this.players = await fetchPlayersByTeam(this.seasonNumber, this.team?.id) this.players = await fetchPlayersByTeam(this.seasonNumber, this.team?.id)
@ -245,7 +245,6 @@ export default {
this.playersInjuredList = await fetchPlayersByTeam(this.seasonNumber, this.teamInjuredList?.id) this.playersInjuredList = await fetchPlayersByTeam(this.seasonNumber, this.teamInjuredList?.id)
this.transactions = (await fetchTransactionsByTeamAndWeek(this.seasonNumber, this.teamAbbreviation, this.transactionsWeekNumber!)) this.transactions = (await fetchTransactionsByTeamAndWeek(this.seasonNumber, this.teamAbbreviation, this.transactionsWeekNumber!))
console.log(this.transactions)
}, },
allPositions(player: Player): string { allPositions(player: Player): string {
let positions = [] let positions = []

View File

@ -1,16 +1,23 @@
{ {
"extends": "@vue/tsconfig/tsconfig.web.json", "extends": "@vue/tsconfig/tsconfig.web.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"], "include": [
"env.d.ts",
"src/**/*",
"src/**/*.vue"
],
"compilerOptions": { "compilerOptions": {
"baseUrl": ".", "baseUrl": ".",
"target": "ES6",
"module": "NodeNext",
"paths": { "paths": {
"@/*": ["./src/*"] "@/*": [
"./src/*"
]
} }
}, },
"references": [ "references": [
{ {
"path": "./tsconfig.config.json" "path": "./tsconfig.config.json"
} }
] ]
} }