Only show game sheet link if authenticated and fix bug with pitcher batter cards in s3 but not s2
This commit is contained in:
parent
0e4487c7a2
commit
d5f52a07bc
@ -6,14 +6,6 @@
|
||||
<p><a id="bbref-link" target="_blank" :href="baseballReferenceUrl">Baseball Reference Page</a></p>
|
||||
</div>
|
||||
<div class="col-sm-auto" v-visible="isAuthenticated" style="width: 940px;">
|
||||
<div class="row">
|
||||
<img v-if="selectedCardImage1Url" style="height:485px; width: 940px;" id="card-image"
|
||||
:src="selectedCardImage1Url">
|
||||
</div>
|
||||
<div class="row">
|
||||
<img v-if="selectedCardImage2Url" style="height:485px; width: 940px;" id="card-image"
|
||||
:src="selectedCardImage2Url">
|
||||
</div>
|
||||
<div class="row">
|
||||
<div v-visible="hasPreviousCard && isAuthenticated" class="col-sm-5">
|
||||
<input type="button" class="w-100" @click="decrementCurrentSeasonNumber" value="<<" />
|
||||
@ -25,6 +17,14 @@
|
||||
<input type="button" class="w-100" @click="incrementCurrentSeasonNumber" value=">>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<img v-if="selectedCardImage1Url" style="height:485px; width: 940px;" id="card-image"
|
||||
:src="selectedCardImage1Url">
|
||||
</div>
|
||||
<div class="row">
|
||||
<img v-if="selectedCardImage2Url" style="height:485px; width: 940px;" id="card-image-2"
|
||||
:src="selectedCardImage2Url">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -72,6 +72,7 @@ export default {
|
||||
return this.cardImage1UrlBySeasonNumber.get(this.currentSeasonNumber)
|
||||
},
|
||||
selectedCardImage2Url(): string | undefined {
|
||||
console.log(this.currentSeasonNumber)
|
||||
if (!this.isAuthenticated || !this.cardImage2UrlBySeasonNumber.has(this.currentSeasonNumber)) return undefined
|
||||
|
||||
return this.cardImage2UrlBySeasonNumber.get(this.currentSeasonNumber)
|
||||
@ -79,8 +80,10 @@ export default {
|
||||
hasPreviousCard(): boolean {
|
||||
const currentImage = this.cardImage1UrlBySeasonNumber.get(this.currentSeasonNumber)
|
||||
let season = this.currentSeasonNumber
|
||||
while (season > 0) {
|
||||
season--
|
||||
while (season > 1) {
|
||||
if (season % 2 === 0) season--
|
||||
else season -= 2
|
||||
|
||||
if (this.cardImage1UrlBySeasonNumber.has(season)
|
||||
&& currentImage !== this.cardImage1UrlBySeasonNumber.get(season)) {
|
||||
return true
|
||||
@ -92,7 +95,9 @@ export default {
|
||||
const currentImage = this.cardImage1UrlBySeasonNumber.get(this.currentSeasonNumber)
|
||||
let season = this.currentSeasonNumber
|
||||
while (season <= CURRENT_SEASON) {
|
||||
season++
|
||||
if (season % 2 === 0) season++
|
||||
else season += 2
|
||||
|
||||
if (this.cardImage1UrlBySeasonNumber.has(season)
|
||||
&& currentImage !== this.cardImage1UrlBySeasonNumber.get(season)) {
|
||||
return true
|
||||
@ -118,8 +123,12 @@ export default {
|
||||
},
|
||||
decrementCurrentSeasonNumber(): void {
|
||||
const currentImage = this.cardImage1UrlBySeasonNumber.get(this.currentSeasonNumber)
|
||||
while (this.currentSeasonNumber > 0) {
|
||||
this.currentSeasonNumber--
|
||||
while (this.currentSeasonNumber > 1) {
|
||||
if (this.currentSeasonNumber % 2 === 0) this.currentSeasonNumber--
|
||||
else this.currentSeasonNumber -= 2
|
||||
|
||||
this.currentSeasonNumber = Math.max(this.currentSeasonNumber, 1)
|
||||
|
||||
if (this.cardImage1UrlBySeasonNumber.has(this.currentSeasonNumber)
|
||||
&& currentImage !== this.cardImage1UrlBySeasonNumber.get(this.currentSeasonNumber)) {
|
||||
break
|
||||
@ -129,7 +138,11 @@ export default {
|
||||
incrementCurrentSeasonNumber(): void {
|
||||
const currentImage = this.cardImage1UrlBySeasonNumber.get(this.currentSeasonNumber)
|
||||
while (this.currentSeasonNumber <= CURRENT_SEASON) {
|
||||
this.currentSeasonNumber++
|
||||
if (this.currentSeasonNumber % 2 === 0) this.currentSeasonNumber++
|
||||
else this.currentSeasonNumber += 2
|
||||
|
||||
this.currentSeasonNumber = Math.min(this.currentSeasonNumber, CURRENT_SEASON)
|
||||
|
||||
if (this.cardImage1UrlBySeasonNumber.has(this.currentSeasonNumber)
|
||||
&& currentImage !== this.cardImage1UrlBySeasonNumber.get(this.currentSeasonNumber)) {
|
||||
break
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
<div class="row">
|
||||
<h6 style="text-align: center;">
|
||||
{{ pitcherDecisions }}
|
||||
<a v-if="sheetsUrl" target="_blank" :href="sheetsUrl" title="Link to scorecard">
|
||||
<a v-if="isAuthenticated && sheetsUrl" target="_blank" :href="sheetsUrl" title="Link to scorecard">
|
||||
🡵
|
||||
</a>
|
||||
</h6>
|
||||
@ -337,6 +337,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import type { Game, Team } from '@/services/apiResponseTypes'
|
||||
import { isDiscordAuthenticated } from '@/services/authenticationService'
|
||||
import { fetchBattingStatsBySeries, type BattingStat } from '@/services/battingStatsService'
|
||||
import { fetchFieldingStatsBySeries, type FieldingStat } from '@/services/fieldingStatsService'
|
||||
import { fetchSingleGame } from '@/services/gameService'
|
||||
@ -348,6 +349,7 @@ export default {
|
||||
name: 'GameView',
|
||||
data() {
|
||||
return {
|
||||
isAuthenticated: false as boolean,
|
||||
team1: undefined as Team | undefined,
|
||||
team2: undefined as Team | undefined,
|
||||
game: undefined as Game | undefined,
|
||||
@ -459,8 +461,10 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
async fetchData(): Promise<void> {
|
||||
[this.team1, this.team2] = await Promise.all(
|
||||
[fetchTeam(this.seasonNumber, this.team1Abbreviation), fetchTeam(this.seasonNumber, this.team2Abbreviation)])
|
||||
this.isAuthenticated = await isDiscordAuthenticated()
|
||||
|
||||
this.team1 = await fetchTeam(this.seasonNumber, this.team1Abbreviation)
|
||||
this.team2 = await fetchTeam(this.seasonNumber, this.team2Abbreviation)
|
||||
|
||||
if (!this.team1 || !this.team2) return
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user