package templates import ( "track-gopher/models" "fmt" "strconv" ) // RaceManage renders the race management view templ RaceManage(heatData *models.HeatData, nextHeat *models.HeatData, groups []models.Group, results []models.HeatResult) { @Layout("Race Management") {

Race Control

{ heatData.Group.Name } - Heat: { strconv.Itoa(heatData.HeatNumber) } of { strconv.Itoa(heatData.TotalHeats) }
Timer Control
Idle
Gate Status: Unknown
@ResultsDisplay(results)
@CurrentHeatDisplay(heatData)
@NextHeatDisplay(nextHeat)
} } templ ResultsDisplay(results []models.HeatResult) {

Heat Results

for _, result := range results { }
Heat Lane 1 Lane 2 Lane 3 Lane 4
{ strconv.Itoa(result.HeatNumber) } { fmt.Sprintf("%.3f", result.Lane1Time) } ({ strconv.Itoa(result.Lane1Position) }) { fmt.Sprintf("%.3f", result.Lane2Time) } ({ strconv.Itoa(result.Lane2Position) }) { fmt.Sprintf("%.3f", result.Lane3Time) } ({ strconv.Itoa(result.Lane3Position) }) { fmt.Sprintf("%.3f", result.Lane4Time) } ({ strconv.Itoa(result.Lane4Position) })
} // Find the current heat templ CurrentHeatDisplay(heatData *models.HeatData) {

Current Heat: { strconv.Itoa(heatData.HeatNumber) }

if heatData.Lane1 != nil { @raceLaneInfo(*heatData.Lane1) } if heatData.Lane2 != nil { @raceLaneInfo(*heatData.Lane2) } if heatData.Lane3 != nil { @raceLaneInfo(*heatData.Lane3) } if heatData.Lane4 != nil { @raceLaneInfo(*heatData.Lane4) }
} // Helper template for displaying a lane in the race manager templ raceLaneInfo(laneData models.LaneData) {
Lane { strconv.Itoa(laneData.Lane) }
{ laneData.Name }

Car #: { laneData.CarNum }

Time: { fmt.Sprintf("%.3f", laneData.Time) }
Position: { strconv.Itoa(laneData.Place) }
} templ NextHeatDisplay(nextHeat *models.HeatData) { if nextHeat != nil {

Next Heat: { strconv.Itoa(nextHeat.HeatNumber) }

if nextHeat.Lane1 != nil { @raceNextHeatRow(*nextHeat.Lane1) } if nextHeat.Lane2 != nil { @raceNextHeatRow(*nextHeat.Lane2) } if nextHeat.Lane3 != nil { @raceNextHeatRow(*nextHeat.Lane3) } if nextHeat.Lane4 != nil { @raceNextHeatRow(*nextHeat.Lane4) }
Lane Racer Car #
} } // Helper template for displaying a racer in the next heat templ nextHeatRacer(laneData models.LaneData) { { strconv.Itoa(laneData.Lane) } { laneData.Name } { laneData.CarNum } }