updated seasons list
This commit is contained in:
@@ -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