66 lines
1.9 KiB
Plaintext
66 lines
1.9 KiB
Plaintext
package seasonsview
|
|
|
|
import "git.haelnorr.com/h/oslstats/internal/db"
|
|
import "time"
|
|
|
|
// StatusBadge renders a season status badge
|
|
// Parameters:
|
|
// - season: pointer to db.Season
|
|
// - compact: bool - true for list view (text only, small), false for detail view (icon + text, large)
|
|
// - useShortLabels: bool - true for "Active/Finals", false for "In Progress/Finals in Progress"
|
|
templ StatusBadge(season *db.Season, compact bool, useShortLabels bool) {
|
|
{{
|
|
now := time.Now()
|
|
status := ""
|
|
statusBg := ""
|
|
|
|
// Determine status based on dates
|
|
if now.Before(season.StartDate) {
|
|
status = "Upcoming"
|
|
statusBg = "bg-blue"
|
|
} else if !season.FinalsStartDate.IsZero() {
|
|
// Finals are scheduled
|
|
if !season.FinalsEndDate.IsZero() && now.After(season.FinalsEndDate.Time) {
|
|
// Finals have ended
|
|
status = "Completed"
|
|
statusBg = "bg-teal"
|
|
} else if now.After(season.FinalsStartDate.Time) {
|
|
// Finals are in progress
|
|
if useShortLabels {
|
|
status = "Finals"
|
|
} else {
|
|
status = "Finals in Progress"
|
|
}
|
|
statusBg = "bg-yellow"
|
|
} else if !season.EndDate.IsZero() && now.After(season.EndDate.Time) {
|
|
// Regular season ended, finals upcoming
|
|
status = "Finals Soon"
|
|
statusBg = "bg-peach"
|
|
} else {
|
|
// Regular season active, finals scheduled for later
|
|
if useShortLabels {
|
|
status = "Active"
|
|
} else {
|
|
status = "In Progress"
|
|
}
|
|
statusBg = "bg-green"
|
|
}
|
|
} else if !season.EndDate.IsZero() && now.After(season.EndDate.Time) {
|
|
// No finals scheduled and regular season ended
|
|
status = "Completed"
|
|
statusBg = "bg-teal"
|
|
} else {
|
|
// Regular season active, no finals scheduled
|
|
if useShortLabels {
|
|
status = "Active"
|
|
} else {
|
|
status = "In Progress"
|
|
}
|
|
statusBg = "bg-green"
|
|
}
|
|
}}
|
|
<span class={ "inline-block px-3 py-1 rounded-full text-sm font-semibold text-mantle " + statusBg }>
|
|
{ status }
|
|
</span>
|
|
}
|