package seasonsview import "git.haelnorr.com/h/oslstats/internal/db" import "fmt" // ==================== Schedule Tab ==================== templ seriesScheduleTab( series *db.PlayoffSeries, currentSchedule *db.PlayoffSeriesSchedule, history []*db.PlayoffSeriesSchedule, canSchedule bool, canManage bool, userTeamID int, ) {
@seriesScheduleStatus(series, currentSchedule, canSchedule, canManage, userTeamID) @seriesScheduleActions(series, currentSchedule, canSchedule, canManage, userTeamID) @seriesScheduleHistory(series, history)
} templ seriesScheduleStatus( series *db.PlayoffSeries, current *db.PlayoffSeriesSchedule, canSchedule bool, canManage bool, userTeamID int, ) { {{ bothTeamsAssigned := series.Team1ID != nil && series.Team2ID != nil }}

Schedule Status

if !bothTeamsAssigned {
⏳

Waiting for Teams

Both teams must be determined before scheduling can begin.

} else if current == nil {
πŸ“…

No time scheduled

if canSchedule { Use the form to propose a time for this series. } else { A team manager needs to propose a time for this series. }

} else if current.Status == db.ScheduleStatusPending && current.ScheduledTime != nil {
⏳

Proposed: @localtime(current.ScheduledTime, "datetime")

Proposed by { current.ProposedBy.Name } β€” awaiting response from the other team

if canSchedule && userTeamID != current.ProposedByTeamID {
} if canSchedule && userTeamID == current.ProposedByTeamID {
}
} else if current.Status == db.ScheduleStatusAccepted {
βœ…

Confirmed: @localtime(current.ScheduledTime, "datetime")

Both teams have agreed on this time.

} else if current.Status == db.ScheduleStatusRejected {
❌

Proposal Rejected

The proposed time was rejected. A new time needs to be proposed.

} else if current.Status == db.ScheduleStatusCancelled {
🚫

Schedule Cancelled

if current.RescheduleReason != nil {

{ *current.RescheduleReason }

}
} else if current.Status == db.ScheduleStatusRescheduled {
πŸ”„

Rescheduled

if current.RescheduleReason != nil {

Reason: { *current.RescheduleReason }

}

A new time needs to be proposed.

} else if current.Status == db.ScheduleStatusPostponed {
⏸️

Postponed

if current.RescheduleReason != nil {

Reason: { *current.RescheduleReason }

}

A new time needs to be proposed.

} else if current.Status == db.ScheduleStatusWithdrawn {
↩️

Proposal Withdrawn

The proposed time was withdrawn. A new time needs to be proposed.

}
} templ seriesScheduleActions( series *db.PlayoffSeries, current *db.PlayoffSeriesSchedule, canSchedule bool, canManage bool, userTeamID int, ) { {{ bothTeamsAssigned := series.Team1ID != nil && series.Team2ID != nil showPropose := false showReschedule := false showPostpone := false showCancel := false if bothTeamsAssigned && canSchedule { if current == nil { showPropose = true } else if current.Status == db.ScheduleStatusRejected { showPropose = true } else if current.Status == db.ScheduleStatusRescheduled { showPropose = true } else if current.Status == db.ScheduleStatusPostponed { showPropose = true } else if current.Status == db.ScheduleStatusWithdrawn { showPropose = true } else if current.Status == db.ScheduleStatusAccepted { showReschedule = true showPostpone = true } } if bothTeamsAssigned && canManage && current != nil && !current.Status.IsTerminal() { showCancel = true } }} if showPropose || showReschedule || showPostpone || showCancel {
if showPropose {

Propose Time

} if showReschedule {

Reschedule

@seriesRescheduleReasonSelect(series)
} if showPostpone {

Postpone

@seriesRescheduleReasonSelect(series)
} if showCancel {

Cancel Schedule

This action will cancel the current series schedule.

}
} else { if !canSchedule && !canManage {

Only team managers can manage series scheduling.

} } } templ seriesRescheduleReasonSelect(series *db.PlayoffSeries) { {{ team1Name := seriesTeamName(series.Team1) team2Name := seriesTeamName(series.Team2) }} } templ seriesScheduleHistory(series *db.PlayoffSeries, history []*db.PlayoffSeriesSchedule) {

Schedule History

if len(history) == 0 {

No scheduling activity yet.

} else {
for i := len(history) - 1; i >= 0; i-- { @seriesScheduleHistoryItem(history[i], i == len(history)-1) }
}
} templ seriesScheduleHistoryItem(schedule *db.PlayoffSeriesSchedule, isCurrent bool) { {{ statusColor := "text-subtext0" statusBg := "bg-surface1" statusLabel := string(schedule.Status) switch schedule.Status { case db.ScheduleStatusPending: statusColor = "text-blue" statusBg = "bg-blue/20" statusLabel = "Pending" case db.ScheduleStatusAccepted: statusColor = "text-green" statusBg = "bg-green/20" statusLabel = "Accepted" case db.ScheduleStatusRejected: statusColor = "text-red" statusBg = "bg-red/20" statusLabel = "Rejected" case db.ScheduleStatusRescheduled: statusColor = "text-yellow" statusBg = "bg-yellow/20" statusLabel = "Rescheduled" case db.ScheduleStatusPostponed: statusColor = "text-peach" statusBg = "bg-peach/20" statusLabel = "Postponed" case db.ScheduleStatusCancelled: statusColor = "text-red" statusBg = "bg-red/20" statusLabel = "Cancelled" case db.ScheduleStatusWithdrawn: statusColor = "text-subtext0" statusBg = "bg-surface1" statusLabel = "Withdrawn" } }}
if isCurrent { CURRENT } { statusLabel }
@localtimeUnix(schedule.CreatedAt, "histdate")
Proposed by: { schedule.ProposedBy.Name }
if schedule.ScheduledTime != nil {
Time: @localtime(schedule.ScheduledTime, "datetime")
} else {
Time: No time set
} if schedule.RescheduleReason != nil {
Reason: { *schedule.RescheduleReason }
}
}