diff --git a/assets/templates/form.tmpl b/assets/templates/form.tmpl index 04ee3d9c9c62ddd9cafea23a792846cb68a59e6d..8fca64f772830ef9830c135976e59d2e7fd3a950 100644 --- a/assets/templates/form.tmpl +++ b/assets/templates/form.tmpl @@ -14,28 +14,57 @@ <div class="contact-form"> <form action="#"> <div class="row"> - {{/* {{if .Team}}*/}} - {{/* <div class="col-md-12">*/}} - {{/* <input name="teamName" type="text" placeholder="Takım Adınız">*/}} - {{/* </div>*/}} - {{/* <div class="col-md-6">*/}} - {{/* <input type="text" placeholder="Takım Kaptanınız">*/}} - {{/* </div>*/}} - {{/* {{end}}*/}} + {{if .team_size.A}} + <div class="col-md-12"> + <label> + <input name="teamName" type="text" placeholder="Takım Adınız"> + </label> + </div> + <div class="col-md-6"> + <label> + <input type="text" placeholder="Takım Kaptanınız"> + </label> + </div> + {{end}} <div class="col-md-6"> - <input type="text" placeholder="Adınız"> + <label> + <input type="text" placeholder="Adınız"> + </label> </div> <div class="col-md-6"> - <input type="text" placeholder="Soyadınız"> + <label> + <input type="text" placeholder="Soyadınız"> + </label> </div> - {{/* {{range $i := loop 1 .TeamSize}}*/}} - - {{/* <div class="col-md-6">*/}} - {{/* <input type="text" placeholder="Player {{ $i }} Name + UID">*/}} - {{/* </div>*/}} - - {{/* {{ end }}*/}} + {{if .team_size.A}} + <div class="col-md-6"> + <label> + <input type="text" placeholder="Player 1 Name + UID"> + </label> + </div> + {{ end }} + {{if .team_size.B}} + <div class="col-md-6"> + <label> + <input type="text" placeholder="Player 2 Name + UID"> + </label> + </div> + {{ end }} + {{if .team_size.C}} + <div class="col-md-6"> + <label> + <input type="text" placeholder="Player 3 Name + UID"> + </label> + </div> + {{ end }} + {{if .team_size.D}} + <div class="col-md-6"> + <label> + <input type="text" placeholder="Player 4 Name + UID"> + </label> + </div> + {{ end }} </div> <button>Gönder</button> </form> diff --git a/routes.go b/routes.go index 47109d06236bdbc8117c8789ad876b62e3bf47f3..87498ec92d274dbc6608bdb044bf1ac0b845ac97 100644 --- a/routes.go +++ b/routes.go @@ -8,6 +8,7 @@ import ( "github.com/google/uuid" "log" "net/http" + "strconv" ) func registerRoutes() { @@ -44,6 +45,33 @@ func registerRoutes() { authText, authRef := getAuthButton(user) + var tsn int + if n, err := strconv.Atoi(t.Attributes["size"]); err != nil { + log.Printf("error parsing team size of team %s: %s", t.ID.String(), err) + context.String(http.StatusInternalServerError, "Internal Server Error") + return + } else { + tsn = n + } + ts := struct { + A bool + B bool + C bool + D bool + }{} + if tsn > 0 { + ts.A = true + } + if tsn > 1 { + ts.B = true + } + if tsn > 2 { + ts.C = true + } + if tsn > 3 { + ts.D = true + } + sy, sm, sd := t.StartTime.Date() dy, dm, dd := t.Deadline.Date() context.HTML(http.StatusOK, "form.tmpl", gin.H{ @@ -56,6 +84,7 @@ func registerRoutes() { TeamSizeString: t.Attributes["size"], Prize: t.Attributes["prize"], }, + "team_size": ts, }) })