updated seasons list
This commit is contained in:
@@ -2,6 +2,7 @@ package page
|
||||
|
||||
import "git.haelnorr.com/h/oslstats/internal/db"
|
||||
import "git.haelnorr.com/h/oslstats/internal/view/layout"
|
||||
import seasoncomp "git.haelnorr.com/h/oslstats/internal/view/component/season"
|
||||
import "time"
|
||||
import "strconv"
|
||||
|
||||
@@ -54,14 +55,14 @@ templ SeasonDetails(season *db.Season) {
|
||||
<div class="flex justify-between items-center">
|
||||
<span class="text-subtext0">Start Date:</span>
|
||||
<span class="text-text font-semibold">
|
||||
{ formatDate(season.StartDate) }
|
||||
{ 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() {
|
||||
{ formatDate(season.EndDate.Time) }
|
||||
{ formatDateLong(season.EndDate.Time) }
|
||||
} else {
|
||||
<span class="text-subtext1 italic">Not set</span>
|
||||
}
|
||||
@@ -90,7 +91,7 @@ templ SeasonDetails(season *db.Season) {
|
||||
<span class="text-subtext0">Start Date:</span>
|
||||
<span class="text-text font-semibold">
|
||||
if !season.FinalsStartDate.IsZero() {
|
||||
{ formatDate(season.FinalsStartDate.Time) }
|
||||
{ formatDateLong(season.FinalsStartDate.Time) }
|
||||
} else {
|
||||
<span class="text-subtext1 italic">Not set</span>
|
||||
}
|
||||
@@ -100,7 +101,7 @@ templ SeasonDetails(season *db.Season) {
|
||||
<span class="text-subtext0">End Date:</span>
|
||||
<span class="text-text font-semibold">
|
||||
if !season.FinalsEndDate.IsZero() {
|
||||
{ formatDate(season.FinalsEndDate.Time) }
|
||||
{ formatDateLong(season.FinalsEndDate.Time) }
|
||||
} else {
|
||||
<span class="text-subtext1 italic">Not set</span>
|
||||
}
|
||||
@@ -124,51 +125,14 @@ templ SeasonDetails(season *db.Season) {
|
||||
<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)
|
||||
@seasoncomp.StatusBadge(season, false, false)
|
||||
</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 {
|
||||
func formatDateLong(t time.Time) string {
|
||||
return t.Format("January 2, 2006")
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ import "git.haelnorr.com/h/oslstats/internal/db"
|
||||
import "git.haelnorr.com/h/oslstats/internal/view/layout"
|
||||
import "git.haelnorr.com/h/oslstats/internal/view/component/pagination"
|
||||
import "git.haelnorr.com/h/oslstats/internal/view/component/sort"
|
||||
import "git.haelnorr.com/h/oslstats/internal/view/component/season"
|
||||
import "fmt"
|
||||
import "time"
|
||||
import "github.com/uptrace/bun"
|
||||
|
||||
templ SeasonsPage(seasons *db.SeasonList) {
|
||||
@@ -18,6 +20,16 @@ templ SeasonsPage(seasons *db.SeasonList) {
|
||||
templ SeasonsList(seasons *db.SeasonList) {
|
||||
{{
|
||||
sortOpts := []db.OrderOpts{
|
||||
{
|
||||
Order: bun.OrderDesc,
|
||||
OrderBy: "start_date",
|
||||
Label: "Start Date (Newest First)",
|
||||
},
|
||||
{
|
||||
Order: bun.OrderAsc,
|
||||
OrderBy: "start_date",
|
||||
Label: "Start Date (Oldest First)",
|
||||
},
|
||||
{
|
||||
Order: bun.OrderAsc,
|
||||
OrderBy: "name",
|
||||
@@ -28,16 +40,6 @@ templ SeasonsList(seasons *db.SeasonList) {
|
||||
OrderBy: "name",
|
||||
Label: "Name (Z-A)",
|
||||
},
|
||||
{
|
||||
Order: bun.OrderAsc,
|
||||
OrderBy: "short_name",
|
||||
Label: "Short Name (A-Z)",
|
||||
},
|
||||
{
|
||||
Order: bun.OrderDesc,
|
||||
OrderBy: "short_name",
|
||||
Label: "Short Name (Z-A)",
|
||||
},
|
||||
}
|
||||
}}
|
||||
<div id="seasons-list-container">
|
||||
@@ -74,12 +76,25 @@ templ SeasonsList(seasons *db.SeasonList) {
|
||||
} else {
|
||||
<!-- Card grid -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
for _, season := range seasons.Seasons {
|
||||
for _, s := range seasons.Seasons {
|
||||
<a
|
||||
class="bg-mantle border border-surface1 rounded-lg p-6 hover:bg-surface0 transition-colors"
|
||||
href={ fmt.Sprintf("/seasons/%s", season.ShortName) }
|
||||
href={ fmt.Sprintf("/seasons/%s", s.ShortName) }
|
||||
>
|
||||
<h3 class="text-xl font-bold text-text mb-2">{ season.Name }</h3>
|
||||
<!-- Header: Name + Status Badge -->
|
||||
<div class="flex justify-between items-start mb-3">
|
||||
<h3 class="text-xl font-bold text-text">{ s.Name }</h3>
|
||||
@season.StatusBadge(&s, true, true)
|
||||
</div>
|
||||
<!-- Info Row: Short Name + Start Date -->
|
||||
<div class="flex items-center gap-3 text-sm">
|
||||
<span class="px-2 py-1 bg-surface1 rounded text-subtext0 font-mono">
|
||||
{ s.ShortName }
|
||||
</span>
|
||||
<span class="text-subtext0">
|
||||
Started: { formatDate(s.StartDate) }
|
||||
</span>
|
||||
</div>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
@@ -90,3 +105,7 @@ templ SeasonsList(seasons *db.SeasonList) {
|
||||
<script src="/static/js/pagination.js"></script>
|
||||
</div>
|
||||
}
|
||||
|
||||
func formatDate(t time.Time) string {
|
||||
return t.Format("02/01/2006") // DD/MM/YYYY
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user