finals stats moved out of regular season stats

This commit is contained in:
2026-03-15 13:11:26 +11:00
parent ea2f82ba9e
commit f98b7b2d88
4 changed files with 350 additions and 6 deletions

View File

@@ -5,20 +5,43 @@ import "git.haelnorr.com/h/oslstats/internal/contexts"
import "git.haelnorr.com/h/oslstats/internal/permissions"
import "fmt"
templ SeasonLeagueFinalsPage(season *db.Season, league *db.League, bracket *db.PlayoffBracket) {
templ SeasonLeagueFinalsPage(
season *db.Season,
league *db.League,
bracket *db.PlayoffBracket,
topGoals []*db.LeagueTopGoalScorer,
topAssists []*db.LeagueTopAssister,
topSaves []*db.LeagueTopSaver,
allStats []*db.LeaguePlayerStats,
) {
@SeasonLeagueLayout("finals", season, league) {
@SeasonLeagueFinals(season, league, bracket)
@SeasonLeagueFinals(season, league, bracket, topGoals, topAssists, topSaves, allStats)
}
}
templ SeasonLeagueFinals(season *db.Season, league *db.League, bracket *db.PlayoffBracket) {
templ SeasonLeagueFinals(
season *db.Season,
league *db.League,
bracket *db.PlayoffBracket,
topGoals []*db.LeagueTopGoalScorer,
topAssists []*db.LeagueTopAssister,
topSaves []*db.LeagueTopSaver,
allStats []*db.LeaguePlayerStats,
) {
{{
permCache := contexts.Permissions(ctx)
canManagePlayoffs := permCache != nil && permCache.HasPermission(permissions.PlayoffsManage)
hasStats := len(topGoals) > 0 || len(topAssists) > 0 || len(topSaves) > 0 || len(allStats) > 0
}}
<div id="finals-content">
if bracket != nil {
@PlayoffBracketView(season, league, bracket)
<!-- Finals Stats Section -->
if hasStats {
<div class="mt-8">
@finalsStatsSection(season, league, topGoals, topAssists, topSaves, allStats)
</div>
}
} else if canManagePlayoffs {
@finalsNotYetConfigured(season, league)
} else {
@@ -27,6 +50,43 @@ templ SeasonLeagueFinals(season *db.Season, league *db.League, bracket *db.Playo
</div>
}
templ finalsStatsSection(
season *db.Season,
league *db.League,
topGoals []*db.LeagueTopGoalScorer,
topAssists []*db.LeagueTopAssister,
topSaves []*db.LeagueTopSaver,
allStats []*db.LeaguePlayerStats,
) {
<script src="/static/js/sortable-table.js"></script>
<div class="space-y-8">
<div class="flex items-center gap-2">
<span class="text-yellow">&#9733;</span>
<h2 class="text-xl font-bold text-text">Finals Stats</h2>
</div>
<!-- Trophy Leaders -->
if len(topGoals) > 0 || len(topAssists) > 0 || len(topSaves) > 0 {
<div class="space-y-4">
<h3 class="text-lg font-bold text-text text-center">Trophy Leaders</h3>
<div class="flex flex-col items-center gap-6 w-full">
<div class="flex flex-col lg:flex-row gap-6 justify-center items-stretch w-full lg:w-auto">
@topGoalScorersTable(season, league, topGoals)
@topAssistersTable(season, league, topAssists)
</div>
@topSaversTable(season, league, topSaves)
</div>
</div>
}
<!-- All Finals Stats -->
if len(allStats) > 0 {
<div class="space-y-4">
<h3 class="text-lg font-bold text-text text-center">All Finals Stats</h3>
@allStatsTable(season, league, allStats)
</div>
}
</div>
}
templ finalsNotYetConfigured(season *db.Season, league *db.League) {
<div class="bg-surface0 border border-surface1 rounded-lg p-8 text-center">
<div class="mb-4">