added teams

This commit is contained in:
2026-02-12 21:10:49 +11:00
parent 2afa32dd63
commit 6e779fa560
25 changed files with 1327 additions and 52 deletions

View File

@@ -7,15 +7,15 @@ import "strconv"
import "git.haelnorr.com/h/oslstats/internal/permissions"
import "git.haelnorr.com/h/oslstats/internal/contexts"
templ DetailPage(season *db.Season) {
templ DetailPage(season *db.Season, leaguesWithTeams []db.LeagueWithTeams) {
@baseview.Layout(season.Name) {
<div class="max-w-screen-2xl mx-auto px-4 py-8">
@SeasonDetails(season)
@SeasonDetails(season, leaguesWithTeams)
</div>
}
}
templ SeasonDetails(season *db.Season) {
templ SeasonDetails(season *db.Season, leaguesWithTeams []db.LeagueWithTeams) {
{{
permCache := contexts.Permissions(ctx)
canEditSeason := permCache.HasPermission(permissions.SeasonsUpdate)
@@ -135,18 +135,41 @@ templ SeasonDetails(season *db.Season) {
<div class="px-6 pb-6">
<div class="bg-surface0 border border-surface1 rounded-lg p-6">
<h2 class="text-2xl font-bold text-text mb-4">Leagues</h2>
if len(season.Leagues) == 0 {
if len(leaguesWithTeams) == 0 {
<p class="text-subtext0 text-sm">No leagues assigned to this season.</p>
} else {
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3">
for _, league := range season.Leagues {
<a
href={ templ.SafeURL("/seasons/" + season.ShortName + "/leagues/" + league.ShortName) }
class="bg-mantle border border-surface1 rounded-lg p-4 hover:bg-surface1 transition-colors"
>
<h3 class="font-semibold text-text mb-1">{ league.Name }</h3>
<span class="text-xs text-subtext0 font-mono">{ league.ShortName }</span>
</a>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
for _, lwt := range leaguesWithTeams {
<div class="bg-mantle border border-surface1 rounded-lg p-4 flex flex-col">
<!-- League Header -->
<a
href={ templ.SafeURL("/seasons/" + season.ShortName + "/leagues/" + lwt.League.ShortName) }
class="mb-3 pb-3 border-b border-surface1"
>
<h3 class="font-semibold text-text text-lg mb-1 hover:text-blue transition-colors">{ lwt.League.Name }</h3>
<span class="text-xs text-subtext0 font-mono">{ lwt.League.ShortName }</span>
</a>
<!-- Teams List -->
<div class="flex-1">
if len(lwt.Teams) == 0 {
<p class="text-sm text-subtext1 italic">No teams yet</p>
} else {
<div class="space-y-2">
for _, team := range lwt.Teams {
<div class="flex items-center gap-2 px-3 py-2 bg-surface0 border border-surface1 rounded hover:bg-surface1 transition-colors">
if team.Color != "" {
<div
class="w-3 h-3 rounded-full border border-surface1 shrink-0"
style={ "background-color: " + templ.SafeCSS(team.Color) }
></div>
}
<span class="text-sm text-text truncate">{ team.Name }</span>
</div>
}
</div>
}
</div>
</div>
}
</div>
}