Only show transactions and bullpen on team page if viewing current season team

This commit is contained in:
Peter 2024-11-09 12:34:09 -06:00
parent a8f6fdd255
commit 5fa26726ff

View File

@ -131,31 +131,38 @@
</table> </table>
</div> </div>
<h3 id="transactions-header">Week {{ transactionsWeekNumber }} Transactions ({{ transactionsWar.toFixed(2) }}) <template v-if="currentSeasonNumber === seasonNumber">
</h3> <h3 id="transactions-header">Week {{ transactionsWeekNumber }} Transactions ({{ transactionsWar.toFixed(2) }})
<div class="table-responsive-xl"> </h3>
<table class="table table-sm table-striped" id="table-transactions"> <div class="table-responsive-xl">
<thead class="thead-dark"> <table class="table table-sm table-striped" id="table-transactions">
<tr> <thead class="thead-dark">
<th>Week</th> <tr>
<th>Player</th> <th>Week</th>
<th>Old Team</th> <th>Player</th>
<th>New Team</th> <th>Old Team</th>
<th>New Team</th>
</tr>
</thead>
<tbody id="transactions-body"></tbody>
<tr v-for="row in transactionRows" :key="row.week">
<td>{{ row.week }}</td>
<td>{{ row.playerName }}</td>
<td>{{ row.oldTeam }}</td>
<td>{{ row.newTeam }}</td>
</tr> </tr>
</thead> </table>
<tbody id="transactions-body"></tbody> </div>
<tr v-for="row in transactionRows" :key="row.week"> </template>
<td>{{ row.week }}</td>
<td>{{ row.playerName }}</td>
<td>{{ row.oldTeam }}</td>
<td>{{ row.newTeam }}</td>
</tr>
</table>
</div>
</div> </div>
</div> </div>
<BullpenTable v-if="weekNumber && team?.id" :season-number="seasonNumber" :week-number="weekNumber" :team-id="team.id" /> <BullpenTable
v-if="currentSeasonNumber === seasonNumber && weekNumber && team?.id"
:season-number="seasonNumber"
:week-number="weekNumber"
:team-id="team.id"
/>
<!-- Schedule --> <!-- Schedule -->
<TeamScheduleTable v-if="!isFreeAgentTeam && team" :season-number="seasonNumber" :team-id="team.id" /> <TeamScheduleTable v-if="!isFreeAgentTeam && team" :season-number="seasonNumber" :team-id="team.id" />
@ -184,7 +191,7 @@
<script lang="ts"> <script lang="ts">
import type { Team } from '@/services/apiResponseTypes' import type { Team } from '@/services/apiResponseTypes'
import { fetchCurrentLeagueInfo } from '@/services/currentService' import { fetchCurrentLeagueInfo, type LeagueInfo } from '@/services/currentService'
import { fetchPlayersByTeam, type Player } from '@/services/playersService' import { fetchPlayersByTeam, type Player } from '@/services/playersService'
import { fetchStandings, type TeamStanding } from '@/services/standingsService' import { fetchStandings, type TeamStanding } from '@/services/standingsService'
import { fetchTeam } from '@/services/teamsService' import { fetchTeam } from '@/services/teamsService'
@ -214,7 +221,8 @@ export default {
playersMinors: [] as Player[], playersMinors: [] as Player[],
playersInjuredList: [] as Player[], playersInjuredList: [] as Player[],
transactions: [] as Transaction[], transactions: [] as Transaction[],
weekNumber: undefined as number | undefined weekNumber: undefined as number | undefined,
currentSeasonNumber: undefined as number | undefined
} }
}, },
props: { props: {
@ -300,7 +308,9 @@ export default {
} }
this.teamStanding = (await fetchStandings(this.seasonNumber)).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 const leagueInfo: LeagueInfo = await fetchCurrentLeagueInfo()
this.currentSeasonNumber = leagueInfo.season
this.weekNumber = leagueInfo.week
this.players = await fetchPlayersByTeam(this.seasonNumber, this.team?.id) this.players = await fetchPlayersByTeam(this.seasonNumber, this.team?.id)
if (!this.isFreeAgentTeam) { if (!this.isFreeAgentTeam) {