we have fixtures ladies and gentleman

This commit is contained in:
2026-02-15 19:56:03 +11:00
parent c5f6fe6098
commit 366aebfdf3
23 changed files with 1355 additions and 78 deletions

View File

@@ -1,15 +1,85 @@
package seasonsview
import "git.haelnorr.com/h/oslstats/internal/db"
import "git.haelnorr.com/h/oslstats/internal/permissions"
import "git.haelnorr.com/h/oslstats/internal/contexts"
import "fmt"
templ SeasonLeagueFixturesPage(season *db.Season, league *db.League) {
templ SeasonLeagueFixturesPage(season *db.Season, league *db.League, fixtures []*db.Fixture) {
@SeasonLeagueLayout("fixtures", season, league) {
@SeasonLeagueFixtures()
@SeasonLeagueFixtures(season, league, fixtures)
}
}
templ SeasonLeagueFixtures() {
<div class="bg-surface0 border border-surface1 rounded-lg p-8 text-center">
<p class="text-subtext0 text-lg">Coming Soon...</p>
templ SeasonLeagueFixtures(season *db.Season, league *db.League, fixtures []*db.Fixture) {
{{
permCache := contexts.Permissions(ctx)
canManage := permCache.HasPermission(permissions.FixturesManage)
// Group fixtures by game week (only allocated ones)
type gameWeekGroup struct {
Week int
Fixtures []*db.Fixture
}
groups := []gameWeekGroup{}
groupMap := map[int]int{} // week -> index in groups
for _, f := range fixtures {
if f.GameWeek == nil {
continue
}
idx, exists := groupMap[*f.GameWeek]
if !exists {
idx = len(groups)
groupMap[*f.GameWeek] = idx
groups = append(groups, gameWeekGroup{Week: *f.GameWeek, Fixtures: []*db.Fixture{}})
}
groups[idx].Fixtures = append(groups[idx].Fixtures, f)
}
}}
<div>
if canManage {
<div class="flex justify-end mb-4">
<a
href={ templ.SafeURL(fmt.Sprintf("/seasons/%s/leagues/%s/fixtures/manage", season.ShortName, league.ShortName)) }
class="rounded-lg px-4 py-2 hover:cursor-pointer text-center text-sm
bg-blue hover:bg-blue/80 text-mantle transition"
>
Manage Fixtures
</a>
</div>
}
if len(groups) == 0 {
<div class="bg-surface0 border border-surface1 rounded-lg p-8 text-center">
<p class="text-subtext0 text-lg">No fixtures scheduled yet.</p>
</div>
} else {
<div class="space-y-4">
for _, group := range groups {
<div class="bg-surface0 border border-surface1 rounded-lg overflow-hidden">
<div class="bg-mantle border-b border-surface1 px-4 py-3">
<h3 class="text-lg font-bold text-text">Game Week { fmt.Sprint(group.Week) }</h3>
</div>
<div class="divide-y divide-surface1">
for _, fixture := range group.Fixtures {
<div class="px-4 py-3 flex items-center justify-between">
<div class="flex items-center gap-3">
<span class="text-xs font-mono text-subtext0 bg-mantle px-2 py-0.5 rounded">
R{ fmt.Sprint(fixture.Round) }
</span>
<span class="text-text">
{ fixture.HomeTeam.Name }
</span>
<span class="text-subtext0 text-sm">vs</span>
<span class="text-text">
{ fixture.AwayTeam.Name }
</span>
</div>
</div>
}
</div>
</div>
}
</div>
}
</div>
}