@ -11,7 +11,6 @@ import templruntime "github.com/a-h/templ/runtime"
import (
import (
"strconv"
"strconv"
"track-gopher/db"
"track-gopher/db"
"track-gopher/derby"
"track-gopher/models"
"track-gopher/models"
)
)
@ -48,7 +47,7 @@ func Heats(groups []models.Group, selectedGroupID int64, db *db.DB) templ.Compon
} ( )
} ( )
}
}
ctx = templ . InitializeContext ( ctx )
ctx = templ . InitializeContext ( ctx )
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 1 , "<div class=\"container py-4\"><h1 class=\"mb-4\">Race Heats Generator</h1><div class=\"mb-4 \"><label for=\"group-select\" class=\"form-label\">Select Group</label> <select id=\"group-select\" class=\"form-select\" hx-get=\"/heats-content\" hx-target=\"#heats-container\" hx-trigger=\"change\" hx-include=\"this\" name=\"group_id \"><option value=\"\">Select a group</option> ")
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 1 , "<div class=\"container py-4\"><h1 class=\"mb-4\">Race Heats </h1><div class=\"row\"><div class=\"col-md-12\"><div class=\"card\"><div class=\"card-body\"><div class=\"mb-3 \"><label for=\"group-select\" class=\"form-label\">Select Group</label> <select class=\"form-select\" id=\"group-select\" hx-get=\"/heats-content\" hx-target=\"#heats-content\" hx-trigger=\"change\" hx-include=\"[name='group_id'] \"><option value=\"\">Select a group</option> ")
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
@ -60,7 +59,7 @@ func Heats(groups []models.Group, selectedGroupID int64, db *db.DB) templ.Compon
var templ_7745c5c3_Var3 string
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3 , templ_7745c5c3_Err = templ . JoinStringErrs ( strconv . FormatInt ( group . ID , 10 ) )
templ_7745c5c3_Var3 , templ_7745c5c3_Err = templ . JoinStringErrs ( strconv . FormatInt ( group . ID , 10 ) )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 28, Col : 53 }
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 31, Col : 50 }
}
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var3 ) )
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var3 ) )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
@ -83,7 +82,7 @@ func Heats(groups []models.Group, selectedGroupID int64, db *db.DB) templ.Compon
var templ_7745c5c3_Var4 string
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4 , templ_7745c5c3_Err = templ . JoinStringErrs ( group . Name )
templ_7745c5c3_Var4 , templ_7745c5c3_Err = templ . JoinStringErrs ( group . Name )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 29, Col : 19 }
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 34, Col : 23 }
}
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var4 ) )
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var4 ) )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
@ -94,22 +93,17 @@ func Heats(groups []models.Group, selectedGroupID int64, db *db.DB) templ.Compon
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
}
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 7 , "</select></div><div id=\"heats-cont ainer \">")
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 7 , "</select></div><div id=\"heats-cont ent \">")
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
if selectedGroupID > 0 {
if selectedGroupID > 0 {
templ_7745c5c3_Err = HeatsContent ( selectedGroupID , groups , db ) . Render ( ctx , templ_7745c5c3_Buffer )
templ_7745c5c3_Err = HeatsContent ( [ ] models . Heat { } , [ ] models . Racer { } ) . Render ( ctx , templ_7745c5c3_Buffer )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else {
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 8 , "<div class=\"alert alert-info\"><p class=\"mb-0\">Please select a group to generate heats.</p></div>" )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
}
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 9, " </div></div>")
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 8 , "</div></div></div></div></div></div>" )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
@ -123,7 +117,7 @@ func Heats(groups []models.Group, selectedGroupID int64, db *db.DB) templ.Compon
} )
} )
}
}
func HeatsContent ( groupID int64 , groups [ ] models . Group , db * db . DB ) templ . Component {
func HeatsContent ( heats [ ] models . Heat , racers [ ] models . Racer ) templ . Component {
return templruntime . GeneratedTemplate ( func ( templ_7745c5c3_Input templruntime . GeneratedComponentInput ) ( templ_7745c5c3_Err error ) {
return templruntime . GeneratedTemplate ( func ( templ_7745c5c3_Input templruntime . GeneratedComponentInput ) ( templ_7745c5c3_Err error ) {
templ_7745c5c3_W , ctx := templ_7745c5c3_Input . Writer , templ_7745c5c3_Input . Context
templ_7745c5c3_W , ctx := templ_7745c5c3_Input . Writer , templ_7745c5c3_Input . Context
if templ_7745c5c3_CtxErr := ctx . Err ( ) ; templ_7745c5c3_CtxErr != nil {
if templ_7745c5c3_CtxErr := ctx . Err ( ) ; templ_7745c5c3_CtxErr != nil {
@ -144,252 +138,88 @@ func HeatsContent(groupID int64, groups []models.Group, db *db.DB) templ.Compone
templ_7745c5c3_Var5 = templ . NopComponent
templ_7745c5c3_Var5 = templ . NopComponent
}
}
ctx = templ . ClearChildren ( ctx )
ctx = templ . ClearChildren ( ctx )
groupRacers , _ := db . GetRacersByGroup ( groupID )
if len ( racers ) == 0 {
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 10 , "<div class=\"card\"><div class=\"card-body\"><div class=\"d-flex justify-content-between align-items-center mb-4\"><h2 class=\"card-title\">Heats for " )
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 9 , "<div class=\"alert alert-info\">No racers in this group yet.</div>" )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6 , templ_7745c5c3_Err = templ . JoinStringErrs ( getGroupName ( groups , groupID ) )
if templ_7745c5c3_Err != nil {
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 56 , Col : 46 }
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var6 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 11 , " (" )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7 , templ_7745c5c3_Err = templ . JoinStringErrs ( strconv . Itoa ( len ( groupRacers ) ) )
if templ_7745c5c3_Err != nil {
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 56 , Col : 82 }
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var7 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 12 , " racers)</h2><div><button class=\"btn btn-primary me-2\" hx-post=\"" )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8 , templ_7745c5c3_Err = templ . JoinStringErrs ( "/api/heats/generate?group_id=" + strconv . FormatInt ( groupID , 10 ) )
if templ_7745c5c3_Err != nil {
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 61 , Col : 80 }
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var8 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 13 , "\" hx-target=\"#heats-list\" hx-swap=\"innerHTML\">Regenerate Heats</button> <button class=\"btn btn-success\" hx-post=\"" )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9 , templ_7745c5c3_Err = templ . JoinStringErrs ( "/api/heats/save?group_id=" + strconv . FormatInt ( groupID , 10 ) )
if templ_7745c5c3_Err != nil {
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 69 , Col : 76 }
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var9 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 14 , "\" hx-target=\"#save-status\">Save Heats</button></div></div><div id=\"save-status\" class=\"mb-4\"></div>" )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if len ( groupRacers ) == 0 {
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 15 , "<div class=\"alert alert-warning mb-4\"><p class=\"mb-0\">No racers in this group. Add racers to generate heats.</p></div>" )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
} else {
} else {
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 16 , "<div id=\"heats-list\">" )
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 10 , "<div class=\"table-responsive\"><table class=\"table table-bordered\"><thead><tr><th>Heat</th><th>Lane 1</th><th>Lane 2</th><th>Lane 3</th><th>Lane 4</th></tr></thead> <tbody>" )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = GeneratedHeats ( groupRacers ) . Render ( ctx , templ_7745c5c3_Buffer )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 17 , "</div>" )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
}
for i , heat := range heats {
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 18 , "</div></div>" )
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 11 , "<tr><td>" )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
} )
}
func GeneratedHeats ( racers [ ] models . Racer ) templ . Component {
return templruntime . GeneratedTemplate ( func ( templ_7745c5c3_Input templruntime . GeneratedComponentInput ) ( templ_7745c5c3_Err error ) {
templ_7745c5c3_W , ctx := templ_7745c5c3_Input . Writer , templ_7745c5c3_Input . Context
if templ_7745c5c3_CtxErr := ctx . Err ( ) ; templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer , templ_7745c5c3_IsBuffer := templruntime . GetBuffer ( templ_7745c5c3_W )
if ! templ_7745c5c3_IsBuffer {
defer func ( ) {
templ_7745c5c3_BufErr := templruntime . ReleaseBuffer ( templ_7745c5c3_Buffer )
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
} ( )
}
ctx = templ . InitializeContext ( ctx )
templ_7745c5c3_Var10 := templ . GetChildren ( ctx )
if templ_7745c5c3_Var10 == nil {
templ_7745c5c3_Var10 = templ . NopComponent
}
ctx = templ . ClearChildren ( ctx )
var derbyRacers [ ] derby . Racer
for _ , racer := range racers {
derbyRacers = append ( derbyRacers , derby . CreateRacer ( racer . ID , racer . FirstName , racer . LastName , racer . CarNumber ) )
}
var heats = derby . GenerateHeats ( derbyRacers )
if len ( heats ) == 0 {
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 19 , "<div class=\"alert alert-warning\"><p class=\"mb-0\">No heats could be generated. Please add more racers.</p></div>" )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else {
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 20 , "<div class=\"row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4\">" )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _ , heat := range heats {
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 21 , "<div class=\"col\"><div class=\"card h-100\"><div class=\"card-body\"><h3 class=\"card-title mb-3\">Heat " )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
var templ_7745c5c3_Var 11 string
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var 11 , templ_7745c5c3_Err = templ . JoinStringErrs ( strconv . Itoa ( heat. HeatNum ) )
templ_7745c5c3_Var6 , templ_7745c5c3_Err = templ . JoinStringErrs ( strconv . Itoa ( i + 1 ) )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 112, Col : 68 }
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 71 , Col : 32 }
}
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var 11 ) )
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var6 ) )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 22, "</h3><table class=\"table table-sm\"><thead><tr><th>Lane</th><th>Racer</th><th>Car #</th></tr></thead> <tbody><tr><td>1 </td><td>")
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 12 , "</td><td>" )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
var templ_7745c5c3_Var 12 string
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var 12 , templ_7745c5c3_Err = templ . JoinStringErrs ( getRacerName ( racers , heat . Lane1ID ) )
templ_7745c5c3_Var7 , templ_7745c5c3_Err = templ . JoinStringErrs ( getRacerName ( racers , heat . Lane1ID ) )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 124, Col : 50 }
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 72 , Col : 47 }
}
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var 12 ) )
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var7 ) )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 2 3, "</td><td>" )
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 13 , "</td><td>" )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
var templ_7745c5c3_Var 13 string
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var 13 , templ_7745c5c3_Err = templ . JoinStringErrs ( getRacer CarNumber( racers , heat . Lane1 ID) )
templ_7745c5c3_Var8 , templ_7745c5c3_Err = templ . JoinStringErrs ( getRacerName ( racers , heat . Lane2ID ) )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 125, Col : 55 }
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 73 , Col : 47 }
}
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var 13 ) )
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var8 ) )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 24, "</td></tr><tr><td>2 </td><td>")
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 14 , "</td><td>" )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
var templ_7745c5c3_Var 14 string
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var 14 , templ_7745c5c3_Err = templ . JoinStringErrs ( getRacerName ( racers , heat . Lane 2 ID) )
templ_7745c5c3_Var9 , templ_7745c5c3_Err = templ . JoinStringErrs ( getRacerName ( racers , heat . Lane3ID ) )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 129, Col : 50 }
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 74 , Col : 47 }
}
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var 14 ) )
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var 9 ) )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 2 5, "</td><td>" )
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 1 5, "</td><td>" )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
var templ_7745c5c3_Var15 string
var templ_7745c5c3_Var10 string
templ_7745c5c3_Var15 , templ_7745c5c3_Err = templ . JoinStringErrs ( getRacerCarNumber ( racers , heat . Lane2ID ) )
templ_7745c5c3_Var10 , templ_7745c5c3_Err = templ . JoinStringErrs ( getRacerName ( racers , heat . Lane4ID ) )
if templ_7745c5c3_Err != nil {
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 130 , Col : 55 }
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var15 ) )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ _7745c5c3_Err
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 75 , Col : 47 }
}
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 26 , "</td></tr><tr><td>3</td><td>" )
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var10 ) )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
var templ_7745c5c3_Var16 string
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 16 , "</td></tr>" )
templ_7745c5c3_Var16 , templ_7745c5c3_Err = templ . JoinStringErrs ( getRacerName ( racers , heat . Lane3ID ) )
if templ_7745c5c3_Err != nil {
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 134 , Col : 50 }
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var16 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 27 , "</td><td>" )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var17 string
templ_7745c5c3_Var17 , templ_7745c5c3_Err = templ . JoinStringErrs ( getRacerCarNumber ( racers , heat . Lane3ID ) )
if templ_7745c5c3_Err != nil {
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 135 , Col : 55 }
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var17 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 28 , "</td></tr><tr><td>4</td><td>" )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var18 string
templ_7745c5c3_Var18 , templ_7745c5c3_Err = templ . JoinStringErrs ( getRacerName ( racers , heat . Lane4ID ) )
if templ_7745c5c3_Err != nil {
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 139 , Col : 50 }
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var18 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 29 , "</td><td>" )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var19 string
templ_7745c5c3_Var19 , templ_7745c5c3_Err = templ . JoinStringErrs ( getRacerCarNumber ( racers , heat . Lane4ID ) )
if templ_7745c5c3_Err != nil {
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` web/templates/heats.templ ` , Line : 140 , Col : 55 }
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var19 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 30 , "</td></tr></tbody></table></div></div></div>" )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
}
}
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 3 1, " </div>")
templ_7745c5c3_Err = templruntime . WriteString ( templ_7745c5c3_Buffer , 17 , "</tbody></table><div class=\"mt-3\"><button class=\"btn btn-primary\" hx-post=\"/api/heats\" hx-include=\"[name='group_id']\" hx-target=\"#heats-content\">Save Heats</button></div></div>" )
if templ_7745c5c3_Err != nil {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
return templ_7745c5c3_Err
}
}
@ -398,39 +228,13 @@ func GeneratedHeats(racers []models.Racer) templ.Component {
} )
} )
}
}
func getGroupName ( groups [ ] models . Group , groupID int64 ) string {
func getRacerName ( racers [ ] models . Racer , id int64 ) string {
for _ , group := range groups {
for _ , r := range racers {
if group . ID == groupID {
if r . ID == id {
return group . Name
return r . FirstName + " " + r . LastName
}
}
return "Unknown Group"
}
func getRacerName ( racers [ ] models . Racer , racerID * int64 ) string {
if racerID == nil {
return "Empty"
}
for _ , racer := range racers {
if racer . ID == * racerID {
return racer . FirstName + " " + racer . LastName
}
}
return "Unknown Racer"
}
func getRacerCarNumber ( racers [ ] models . Racer , racerID * int64 ) string {
if racerID == nil {
return "-"
}
for _ , racer := range racers {
if racer . ID == * racerID {
return racer . CarNumber
}
}
}
}
return " - "
return "TBD"
}
}
var _ = templruntime . GeneratedTemplate
var _ = templruntime . GeneratedTemplate