From b9bc29d5bc9203247ed6c0170079e57e6bf24cec Mon Sep 17 00:00:00 2001 From: H3ALY Date: Wed, 29 Oct 2025 11:37:35 +0000 Subject: [PATCH] fix loading of ticket add page --- internal/handlers/account/tickets/add.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/internal/handlers/account/tickets/add.go b/internal/handlers/account/tickets/add.go index 84d0dcf..0b7849d 100644 --- a/internal/handlers/account/tickets/add.go +++ b/internal/handlers/account/tickets/add.go @@ -24,6 +24,8 @@ import ( "strconv" "time" + templateHandlers "synlotto-website/internal/handlers/template" + templateHelpers "synlotto-website/internal/helpers/template" ticketStorage "synlotto-website/internal/storage/tickets" "synlotto-website/internal/models" @@ -37,10 +39,17 @@ import ( const sessionKeyUserID = "UserID" func AddGet(c *gin.Context) { - c.HTML(http.StatusOK, "account/tickets/add_ticket.html", gin.H{ - "title": "Add Ticket", - "csrfToken": nosurf.Token(c.Request), - }) + app := c.MustGet("app").(*bootstrap.App) + data := templateHandlers.BuildTemplateData(app, c.Writer, c.Request) + ctx := templateHelpers.TemplateContext(c.Writer, c.Request, data) + tmpl := templateHelpers.LoadTemplateFiles("layout.html", "web/templates/account/tickets/add_ticket.html") + + c.Header("Content-Type", "text/html; charset=utf-8") + if err := tmpl.ExecuteTemplate(c.Writer, "account/tickets/add_ticket.html", ctx); err != nil { + c.String(http.StatusInternalServerError, "render error: %v", err) + return + } + c.Status(http.StatusOK) } func AddPost(c *gin.Context) {