166 lines
5.0 KiB
Plaintext
166 lines
5.0 KiB
Plaintext
package seasonsview
|
|
|
|
import "git.haelnorr.com/h/oslstats/internal/db"
|
|
import "git.haelnorr.com/h/oslstats/internal/view/baseview"
|
|
import "time"
|
|
import "strconv"
|
|
|
|
templ DetailPage(season *db.Season) {
|
|
@baseview.Layout(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">
|
|
{ formatDateLong(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() {
|
|
{ formatDateLong(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() {
|
|
{ formatDateLong(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() {
|
|
{ formatDateLong(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">
|
|
@StatusBadge(season, false, false)
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
func formatDateLong(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"
|
|
}
|
|
}
|