203 lines
6.1 KiB
Plaintext
203 lines
6.1 KiB
Plaintext
package page
|
|
|
|
import "git.haelnorr.com/h/oslstats/internal/db"
|
|
import "git.haelnorr.com/h/oslstats/internal/view/layout"
|
|
import "time"
|
|
import "strconv"
|
|
|
|
templ SeasonPage(season *db.Season) {
|
|
@layout.Global(season.Name) {
|
|
<div class="max-w-screen-2xl mx-auto px-4 py-8">
|
|
@SeasonDetails(season)
|
|
</div>
|
|
}
|
|
}
|
|
|
|
templ SeasonDetails(season *db.Season) {
|
|
<div class="bg-mantle border border-surface1 rounded-lg overflow-hidden">
|
|
<!-- Header Section -->
|
|
<div class="bg-surface0 border-b border-surface1 px-6 py-8">
|
|
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
|
|
<div>
|
|
<h1 class="text-4xl font-bold text-text mb-2">{ season.Name }</h1>
|
|
<span class="inline-block bg-blue px-3 py-1 rounded-full text-sm font-semibold text-mantle">
|
|
{ season.ShortName }
|
|
</span>
|
|
</div>
|
|
<div class="flex gap-2">
|
|
<a
|
|
href={ templ.SafeURL("/seasons/" + season.ShortName + "/edit") }
|
|
class="rounded-lg px-4 py-2 hover:cursor-pointer text-center
|
|
bg-blue hover:bg-blue/75 text-mantle transition"
|
|
>
|
|
Edit
|
|
</a>
|
|
<a
|
|
href="/seasons"
|
|
class="rounded-lg px-4 py-2 hover:cursor-pointer text-center
|
|
bg-surface1 hover:bg-surface2 text-text transition"
|
|
>
|
|
Back to Seasons
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- Information Grid -->
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 p-6">
|
|
<!-- Regular Season Section -->
|
|
<div class="bg-surface0 border border-surface1 rounded-lg p-6">
|
|
<h2 class="text-2xl font-bold text-text mb-4 flex items-center gap-2">
|
|
<span class="text-blue">●</span>
|
|
Regular Season
|
|
</h2>
|
|
<div class="space-y-3">
|
|
<div class="flex justify-between items-center">
|
|
<span class="text-subtext0">Start Date:</span>
|
|
<span class="text-text font-semibold">
|
|
{ formatDate(season.StartDate) }
|
|
</span>
|
|
</div>
|
|
<div class="flex justify-between items-center">
|
|
<span class="text-subtext0">End Date:</span>
|
|
<span class="text-text font-semibold">
|
|
if !season.EndDate.IsZero() {
|
|
{ formatDate(season.EndDate.Time) }
|
|
} else {
|
|
<span class="text-subtext1 italic">Not set</span>
|
|
}
|
|
</span>
|
|
</div>
|
|
<div class="flex justify-between items-center">
|
|
<span class="text-subtext0">Duration:</span>
|
|
<span class="text-text font-semibold">
|
|
if !season.EndDate.IsZero() {
|
|
{ formatDuration(season.StartDate, season.EndDate.Time) }
|
|
} else {
|
|
<span class="text-subtext1 italic">Ongoing</span>
|
|
}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- Finals Section -->
|
|
<div class="bg-surface0 border border-surface1 rounded-lg p-6">
|
|
<h2 class="text-2xl font-bold text-text mb-4 flex items-center gap-2">
|
|
<span class="text-yellow">★</span>
|
|
Finals
|
|
</h2>
|
|
<div class="space-y-3">
|
|
<div class="flex justify-between items-center">
|
|
<span class="text-subtext0">Start Date:</span>
|
|
<span class="text-text font-semibold">
|
|
if !season.FinalsStartDate.IsZero() {
|
|
{ formatDate(season.FinalsStartDate.Time) }
|
|
} else {
|
|
<span class="text-subtext1 italic">Not set</span>
|
|
}
|
|
</span>
|
|
</div>
|
|
<div class="flex justify-between items-center">
|
|
<span class="text-subtext0">End Date:</span>
|
|
<span class="text-text font-semibold">
|
|
if !season.FinalsEndDate.IsZero() {
|
|
{ formatDate(season.FinalsEndDate.Time) }
|
|
} else {
|
|
<span class="text-subtext1 italic">Not set</span>
|
|
}
|
|
</span>
|
|
</div>
|
|
<div class="flex justify-between items-center">
|
|
<span class="text-subtext0">Duration:</span>
|
|
<span class="text-text font-semibold">
|
|
if !season.FinalsStartDate.IsZero() && !season.FinalsEndDate.IsZero() {
|
|
{ formatDuration(season.FinalsStartDate.Time, season.FinalsEndDate.Time) }
|
|
} else {
|
|
<span class="text-subtext1 italic">Not scheduled</span>
|
|
}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- Status Section -->
|
|
<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">Status</h2>
|
|
<div class="flex items-center gap-3">
|
|
@SeasonStatus(season)
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
templ SeasonStatus(season *db.Season) {
|
|
{{
|
|
now := time.Now()
|
|
status := ""
|
|
statusColor := ""
|
|
statusBg := ""
|
|
|
|
if now.Before(season.StartDate) {
|
|
status = "Upcoming"
|
|
statusColor = "text-blue"
|
|
statusBg = "bg-blue/10 border-blue"
|
|
} else if !season.EndDate.IsZero() && now.After(season.EndDate.Time) {
|
|
status = "Completed"
|
|
statusColor = "text-green"
|
|
statusBg = "bg-green/10 border-green"
|
|
} else if !season.FinalsStartDate.IsZero() && now.After(season.FinalsStartDate.Time) {
|
|
if !season.FinalsEndDate.IsZero() && now.After(season.FinalsEndDate.Time) {
|
|
status = "Completed"
|
|
statusColor = "text-green"
|
|
statusBg = "bg-green/10 border-green"
|
|
} else {
|
|
status = "Finals in Progress"
|
|
statusColor = "text-yellow"
|
|
statusBg = "bg-yellow/10 border-yellow"
|
|
}
|
|
} else {
|
|
status = "In Progress"
|
|
statusColor = "text-green"
|
|
statusBg = "bg-green/10 border-green"
|
|
}
|
|
}}
|
|
<div class={ "px-4 py-2 rounded-lg border-2 inline-flex items-center gap-2 " + statusBg }>
|
|
<span class={ "text-2xl " + statusColor }>●</span>
|
|
<span class={ "text-lg font-semibold " + statusColor }>{ status }</span>
|
|
</div>
|
|
}
|
|
|
|
func formatDate(t time.Time) string {
|
|
return t.Format("January 2, 2006")
|
|
}
|
|
|
|
func formatDuration(start, end time.Time) string {
|
|
days := int(end.Sub(start).Hours() / 24)
|
|
if days == 0 {
|
|
return "Same day"
|
|
} else if days == 1 {
|
|
return "1 day"
|
|
} else if days < 7 {
|
|
return strconv.Itoa(days) + " days"
|
|
} else if days < 30 {
|
|
weeks := days / 7
|
|
if weeks == 1 {
|
|
return "1 week"
|
|
}
|
|
return strconv.Itoa(weeks) + " weeks"
|
|
} else if days < 365 {
|
|
months := days / 30
|
|
if months == 1 {
|
|
return "1 month"
|
|
}
|
|
return strconv.Itoa(months) + " months"
|
|
} else {
|
|
years := days / 365
|
|
if years == 1 {
|
|
return "1 year"
|
|
}
|
|
return strconv.Itoa(years) + " years"
|
|
}
|
|
}
|