diff --git a/internal/app/handlers/page_handler.go b/internal/app/handlers/page_handler.go index 1f87c36..82d3d62 100644 --- a/internal/app/handlers/page_handler.go +++ b/internal/app/handlers/page_handler.go @@ -15,21 +15,21 @@ func LoginPage(ctx *gin.Context) { title := "Potion - Login" page := pages.LoginPage() - ctx.HTML(200, "", layouts.AppLayout(title, page)) + ctx.HTML(http.StatusOK, "", layouts.AppLayout(title, page)) } func HomePage(ctx *gin.Context) { title := "Potion - Home" page := pages.HomePage() - ctx.HTML(200, "", layouts.AppLayout(title, page)) + ctx.HTML(http.StatusOK, "", layouts.AppLayout(title, page)) } func FavoritesPage(ctx *gin.Context) { title := "Potion - Favorites" page := pages.FavoritesPage() - ctx.HTML(200, "", layouts.AppLayout(title, page)) + ctx.HTML(http.StatusOK, "", layouts.AppLayout(title, page)) } func CreatePage(ctx *gin.Context) { @@ -42,7 +42,7 @@ func CreatePage(ctx *gin.Context) { title := "Potion - Create" page := pages.CreatePage() - ctx.HTML(200, "", layouts.AppLayout(title, page)) + ctx.HTML(http.StatusOK, "", layouts.AppLayout(title, page)) } func ProfilePage(ctx *gin.Context) { @@ -59,14 +59,14 @@ func ProfilePage(ctx *gin.Context) { title := "Potion - Profile" page := pages.ProfilePage(user) - ctx.HTML(200, "", layouts.AppLayout(title, page)) + ctx.HTML(http.StatusOK, "", layouts.AppLayout(title, page)) } func ListPage(ctx *gin.Context) { title := "Potion - Shopping List" page := pages.ListPage() - ctx.HTML(200, "", layouts.AppLayout(title, page)) + ctx.HTML(http.StatusOK, "", layouts.AppLayout(title, page)) } // TODO: Figure out how to handle errors, think we just need a simple display. @@ -102,5 +102,14 @@ func RecipePage(ctx *gin.Context) { title := "Potion - View Recipe" page := pages.RecipePage(*recipe, *user) - ctx.HTML(200, "", layouts.AppLayout(title, page)) + ctx.HTML(http.StatusOK, "", layouts.AppLayout(title, page)) +} + +func SearchPage(ctx *gin.Context) { + title := "Potion - Recipe Search" + page := pages.SearchPage() + + fmt.Println("I OPENED A PAGE!") + + ctx.HTML(http.StatusOK, "", layouts.AppLayout(title, page)) } diff --git a/internal/app/handlers/recipe_handler.go b/internal/app/handlers/recipe_handler.go index 7854a98..2490927 100644 --- a/internal/app/handlers/recipe_handler.go +++ b/internal/app/handlers/recipe_handler.go @@ -6,14 +6,9 @@ import ( "github.com/gin-gonic/gin" domain "github.com/haydenhargreaves/Potion/internal/domain/server" + templates "github.com/haydenhargreaves/Potion/internal/templates/pages" ) -const CREATE_SUCCESS_HTML = ` -
- Success! Your new masterpiece was created! -
-` - const CREATE_ERROR_HTML = `Uh oh! Something went wrong when creating your recipe. Please try again. %s @@ -42,5 +37,8 @@ func SearchRecipes(ctx *gin.Context) { if err != nil { ctx.JSON(http.StatusOK, gin.H{"error": err.Error()}) } - ctx.JSON(http.StatusOK, gin.H{"recipes": recipes}) + + // Render content as the response + ctx.Status(200) + templates.ResultList(recipes).Render(ctx.Request.Context(), ctx.Writer) } diff --git a/internal/app/server/server.go b/internal/app/server/server.go index b972deb..5ec329f 100644 --- a/internal/app/server/server.go +++ b/internal/app/server/server.go @@ -165,6 +165,7 @@ func (s *Server) Setup() *Server { router_web.GET("/profile", handlers.ProfilePage) router_web.GET("/list", handlers.ListPage) router_web.GET("/recipe/:id", handlers.RecipePage) + router_web.GET("/search", handlers.SearchPage) // WEB state endpoints router_state.POST("/tags", handlers.NewTag) diff --git a/internal/infrastructure/database/repository/recipe_repository.go b/internal/infrastructure/database/repository/recipe_repository.go index 6727448..973e6c2 100644 --- a/internal/infrastructure/database/repository/recipe_repository.go +++ b/internal/infrastructure/database/repository/recipe_repository.go @@ -259,6 +259,8 @@ func (r *RecipeRepository) SearchRecipes(filters domain.SearchFilters) ([]domain query += ";" } + fmt.Println(query) + // Execute the query rows, err := tx.Query(query) if err != nil { diff --git a/internal/templates/components/dropdowns.templ b/internal/templates/components/dropdowns.templ index 226efc8..43f858d 100644 --- a/internal/templates/components/dropdowns.templ +++ b/internal/templates/components/dropdowns.templ @@ -1,19 +1,17 @@ package components templ dropdownButton(content, name, value string) { - + } templ FilterDropdown() { - -
-} + + } diff --git a/internal/templates/components/dropdowns_templ.go b/internal/templates/components/dropdowns_templ.go index e6605c4..4a1373d 100644 --- a/internal/templates/components/dropdowns_templ.go +++ b/internal/templates/components/dropdowns_templ.go @@ -29,7 +29,7 @@ func dropdownButton(content, name, value string) templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "