From 045dc13fbeb84367ba89aad471d97278fb3d65e9 Mon Sep 17 00:00:00 2001
From: Hayden Hargreaves
Date: Wed, 16 Jul 2025 18:57:36 -0700
Subject: [PATCH] (FEAT): Created favorites search route which allows for
better search.
This basically marks the favorites page completed. Updating the recipe
repository to allow the search function to accept a userId and favorites
flag. This flag will toggle a "favorites only" search. Which can be used
to replicate the same functionality from the search page in the
favorites page. This later can serve as a baseline for updating to also
work for activity search.
I am starting to think an ORM is a good idea...I heard Gorm is good, but
for now, there is a bit too much tech debt.
---
internal/app/handlers/page_handler.go | 35 +-
internal/app/handlers/recipe_handler.go | 59 +++-
internal/app/server/server.go | 1 +
internal/app/service/recipe_service.go | 6 +-
internal/domain/recipe/repository.go | 2 +-
internal/domain/recipe/service.go | 2 +-
internal/domain/server/routes.go | 1 +
.../database/repository/recipe_repository.go | 54 ++-
.../templates/components/search_bar.templ | 8 +-
.../templates/components/search_bar_templ.go | 102 +++---
internal/templates/pages/favorites.templ | 71 +++-
internal/templates/pages/favorites_templ.go | 212 +++++++++++-
internal/templates/pages/home.templ | 174 +++++-----
internal/templates/pages/home_templ.go | 2 +-
internal/templates/pages/profile.templ | 307 +++++++++---------
internal/templates/pages/profile_templ.go | 237 ++++++++------
internal/templates/pages/search.templ | 8 +-
internal/templates/pages/search_templ.go | 4 +-
18 files changed, 845 insertions(+), 440 deletions(-)
diff --git a/internal/app/handlers/page_handler.go b/internal/app/handlers/page_handler.go
index 512d537..26c43a3 100644
--- a/internal/app/handlers/page_handler.go
+++ b/internal/app/handlers/page_handler.go
@@ -29,8 +29,41 @@ func HomePage(ctx *gin.Context) {
}
func FavoritesPage(ctx *gin.Context) {
+ // If not logged in, direct to the login page
+ if !domainServer.IsLoggedIn(ctx) {
+ ctx.Redirect(http.StatusSeeOther, domainServer.WEB_LOGIN)
+ return
+ }
+
title := "Potion - Favorites"
- page := pages.FavoritesPage()
+ var page templ.Component
+
+ // Get filters from cookies
+ if bytes, err := ctx.Cookie("search-filters"); err != nil {
+ fmt.Printf("ERROR: Failed to get search-filter cookie. %s\n", err.Error())
+ page = pages.FavoritesPage(domainRecipe.SearchFilters{})
+ } else {
+ var filters domainRecipe.SearchFilters
+ if err := json.Unmarshal([]byte(bytes), &filters); err != nil {
+ fmt.Printf("ERROR: Failed to unmarshal search-filter cookie. %s\n", err.Error())
+ page = pages.FavoritesPage(domainRecipe.SearchFilters{})
+ } else {
+ page = pages.FavoritesPage(filters)
+ }
+ }
+
+ // Else, get the user's favorites
+ // BUG: Depreciated, not displaying a list, using search to drive this page as well
+ // deps := ctx.MustGet("deps").(*domainServer.InjectedDependencies)
+ // userId := ctx.MustGet("userId").(int)
+ // recipes, err := deps.RecipeService.GetUserFavoriteRecipes(userId)
+ // if err != nil {
+ // ctx.JSON(http.StatusInternalServerError, gin.H{
+ // "status": http.StatusInternalServerError,
+ // "message": fmt.Sprintf("Error getting favorites. %s\n", err.Error()),
+ // })
+ // return
+ // }
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 a256307..b245a77 100644
--- a/internal/app/handlers/recipe_handler.go
+++ b/internal/app/handlers/recipe_handler.go
@@ -47,6 +47,48 @@ func toBits(arr []string) (bits int) {
func SearchRecipes(ctx *gin.Context) {
deps := ctx.MustGet("deps").(*domain.InjectedDependencies)
+ // create filters
+ filters := domainRecipe.SearchFilters{
+ Search: ctx.PostForm("search"), // string, search query for titles
+ MealType: toBits(ctx.PostFormArray("meal")),
+ Time: toBits(ctx.PostFormArray("time")),
+ Difficulty: toBits(ctx.PostFormArray("difficulty")),
+ ServingSize: toBits(ctx.PostFormArray("serving")),
+ }
+
+ // Set the filters into the cookies, so they can be reloaded
+ if bytes, err := json.Marshal(filters); err == nil {
+ ctx.SetCookie(
+ "search-filters",
+ string(bytes),
+ int(time.Now().Add(24*time.Hour).Sub(time.Now()).Seconds()),
+ "/",
+ "", // TODO: Need an actual domain
+ false, // TODO: True in prod
+ true,
+ )
+ }
+
+ redirect := ctx.PostForm("redirect")
+ if redirect == "true" {
+ ctx.Header("HX-Redirect", domain.WEB_SEARCH)
+ ctx.Status(http.StatusOK)
+ return
+ }
+
+ // We don't care about favorite status, so use nil and false
+ recipes, err := deps.RecipeService.SearchRecipes(filters, nil, false)
+ if err != nil {
+ ctx.JSON(http.StatusOK, gin.H{"error": err.Error()})
+ }
+
+ // Render content as the response
+ ctx.Status(200)
+ templates.ResultList(recipes).Render(ctx.Request.Context(), ctx.Writer)
+}
+
+func SearchRecipesFavorites(ctx *gin.Context) {
+ deps := ctx.MustGet("deps").(*domain.InjectedDependencies)
// create filters
filters := domainRecipe.SearchFilters{
@@ -62,22 +104,19 @@ func SearchRecipes(ctx *gin.Context) {
ctx.SetCookie(
"search-filters",
string(bytes),
- int(time.Now().Add(24 * time.Hour).Sub(time.Now()).Seconds()),
+ int(time.Now().Add(24*time.Hour).Sub(time.Now()).Seconds()),
"/",
- "", // TODO: Need an actual domain
- false, // TODO: True in prod
+ "", // TODO: Need an actual domain
+ false, // TODO: True in prod
true,
)
}
- redirect := ctx.PostForm("redirect")
- if redirect == "true" {
- ctx.Header("HX-Redirect", domain.WEB_SEARCH)
- ctx.Status(http.StatusOK)
- return
- }
+ // TODO: Error here if they're not logged in?
+ // Get user data (they should be logged in)
+ userId := ctx.MustGet("userId").(int)
- recipes, err := deps.RecipeService.SearchRecipes(filters)
+ recipes, err := deps.RecipeService.SearchRecipes(filters, &userId, true)
if err != nil {
ctx.JSON(http.StatusOK, gin.H{"error": err.Error()})
}
diff --git a/internal/app/server/server.go b/internal/app/server/server.go
index 479ec37..325582a 100644
--- a/internal/app/server/server.go
+++ b/internal/app/server/server.go
@@ -184,6 +184,7 @@ func (s *Server) Setup() *Server {
// Recipe endpoints
router_api.POST("/recipe", handlers.CreateRecipe)
router_api.POST("/recipe/search", handlers.SearchRecipes)
+ router_api.POST("/recipe/search/favorites", handlers.SearchRecipesFavorites)
router_api.GET("/user/recipes", handlers.GetUserRecipes)
router_api.GET("/user/favorites", handlers.GetUserFavoriteRecipes)
diff --git a/internal/app/service/recipe_service.go b/internal/app/service/recipe_service.go
index 22fe6a1..c0ceb3f 100644
--- a/internal/app/service/recipe_service.go
+++ b/internal/app/service/recipe_service.go
@@ -151,8 +151,10 @@ func (s *RecipeService) GetRecipe(id int, userId *int) (*domain.Recipe, error) {
// the filter is provided.
// A function `isBitActive` in the recipe repository provides an example of
// testing of testing the filter parsing.
-func (s *RecipeService) SearchRecipes(filters domain.SearchFilters) ([]domain.Recipe, error) {
- return s.recipeRepository.SearchRecipes(filters)
+//
+// The favorites parameter is used to only return filters favorited by the userId provided.
+func (s *RecipeService) SearchRecipes(filters domain.SearchFilters, userId *int, favorites bool) ([]domain.Recipe, error) {
+ return s.recipeRepository.SearchRecipes(filters, userId, favorites)
}
// GetUserRecipes returns a list of the recipes that the user has created. The user's
diff --git a/internal/domain/recipe/repository.go b/internal/domain/recipe/repository.go
index 639d21c..f0c69ad 100644
--- a/internal/domain/recipe/repository.go
+++ b/internal/domain/recipe/repository.go
@@ -3,7 +3,7 @@ package domain
type RecipeRepository interface {
CreateRecipe(recipe *Recipe) error
GetRecipe(id int, userId *int) (*Recipe, error)
- SearchRecipes(filters SearchFilters) ([]Recipe, error)
+ SearchRecipes(filters SearchFilters, userId *int, favorites bool) ([]Recipe, error)
CreateRecipeTags(recipe Recipe, tags []string) error
GetUserRecipes(id int) ([]Recipe, error)
GetUserFavoriteRecipes(id int) ([]Recipe, error)
diff --git a/internal/domain/recipe/service.go b/internal/domain/recipe/service.go
index 425b83e..51d4bd6 100644
--- a/internal/domain/recipe/service.go
+++ b/internal/domain/recipe/service.go
@@ -5,7 +5,7 @@ import "github.com/gin-gonic/gin"
type RecipeService interface {
CreateRecipe(ctx *gin.Context) (*Recipe, error)
GetRecipe(id int, userId *int) (*Recipe, error)
- SearchRecipes(filters SearchFilters) ([]Recipe, error)
+ SearchRecipes(filters SearchFilters, userId *int, favorites bool) ([]Recipe, error)
GetUserRecipes(id int) ([]Recipe, error)
GetUserFavoriteRecipes(id int) ([]Recipe, error)
}
diff --git a/internal/domain/server/routes.go b/internal/domain/server/routes.go
index b6823da..19053ce 100644
--- a/internal/domain/server/routes.go
+++ b/internal/domain/server/routes.go
@@ -24,6 +24,7 @@ const API_AUTH_CALLBACK = VERSION + API + "/auth/callback"
const API_AUTH_LOGOUT = VERSION + API + "/auth/logout"
const API_CREATE_RECIPE = VERSION + API + "/recipe"
const API_SEARCH_RECIPES = VERSION + API + "/recipe/search"
+const API_SEARCH_FAVORITES = VERSION + API + "/recipe/search/favorites"
const API_ENGAGEMENT_VIEW = VERSION + API + "/engagement/view/%d"
const API_ENGAGEMENT_SHARE = VERSION + API + "/engagement/share/%d"
diff --git a/internal/infrastructure/database/repository/recipe_repository.go b/internal/infrastructure/database/repository/recipe_repository.go
index 4347ce4..94f734b 100644
--- a/internal/infrastructure/database/repository/recipe_repository.go
+++ b/internal/infrastructure/database/repository/recipe_repository.go
@@ -184,8 +184,10 @@ func isBitActive(bits, pos int) bool {
// description can be found in the recipe service implementation. Any errors will be bubbled to the
// caller.
//
+// The favorites parameter is used to only return filters favorited by the userId provided.
+//
// TODO: Pagination is required, to provide infinite scroll.
-func (r *RecipeRepository) SearchRecipes(filters domain.SearchFilters) ([]domain.Recipe, error) {
+func (r *RecipeRepository) SearchRecipes(filters domain.SearchFilters, userId *int, favorites bool) ([]domain.Recipe, error) {
tx, err := r.db.Begin()
if err != nil {
tx.Rollback()
@@ -274,20 +276,25 @@ func (r *RecipeRepository) SearchRecipes(filters domain.SearchFilters) ([]domain
// Define columns to select. More fields can be added if the full text search is required
columns := []string{
- "id",
- "title",
- "description",
- "instructions",
- "serves",
- "difficulty",
- "duration",
- "category",
- "ingredients",
- "userid",
- "modified",
- "created",
+ "r.id",
+ "r.title",
+ "r.description",
+ "r.instructions",
+ "r.serves",
+ "r.difficulty",
+ "r.duration",
+ "r.category",
+ "r.ingredients",
+ "r.userid",
+ "r.modified",
+ "r.created",
}
+ // TODO: Need to add these to the query
+
+ // FROM ... JOIN favorites f ON f.recipeId = r.id
+ // WHERE ... AND f.userId = 3
+
// Create search vector query
var orderBy string = ""
if filters.Search != "" {
@@ -295,19 +302,30 @@ func (r *RecipeRepository) SearchRecipes(filters domain.SearchFilters) ([]domain
conditions = append(
conditions,
- fmt.Sprintf("search_vector @@ to_tsquery('english', '%s')", vector_query),
+ fmt.Sprintf("r.search_vector @@ to_tsquery('english', '%s')", vector_query),
)
template := `
ORDER BY
- ts_rank(search_vector, to_tsquery('english', '%s')) DESC,
- ts_rank_cd(search_vector, to_tsquery('english', '%s')) DESC
+ ts_rank(r.search_vector, to_tsquery('english', '%s')) DESC,
+ ts_rank_cd(r.search_vector, to_tsquery('english', '%s')) DESC
`
orderBy = fmt.Sprintf(template, vector_query, vector_query)
}
// Generate the query
- query := fmt.Sprintf("SELECT %s FROM recipes", strings.Join(columns, ","))
+ var query string
+ if favorites && userId != nil {
+ query = fmt.Sprintf(
+ "SELECT %s FROM recipes r JOIN favorites f ON f.recipeId = r.id",
+ strings.Join(columns, ","),
+ )
+
+ // Add new favorite condition to the conditions list
+ conditions = append(conditions, fmt.Sprintf("f.userid = %d", *userId))
+ } else {
+ query = fmt.Sprintf("SELECT %s FROM recipes r", strings.Join(columns, ","))
+ }
// Convert and append conditions if provided
if len(conditions) > 0 {
@@ -323,6 +341,8 @@ func (r *RecipeRepository) SearchRecipes(filters domain.SearchFilters) ([]domain
// Finish it off with a colon!
query += ";"
+ fmt.Printf("QUERY: %s\n", query)
+
// Execute the query
rows, err := tx.Query(query)
if err != nil {
diff --git a/internal/templates/components/search_bar.templ b/internal/templates/components/search_bar.templ
index 3d4071f..a2e5613 100644
--- a/internal/templates/components/search_bar.templ
+++ b/internal/templates/components/search_bar.templ
@@ -3,9 +3,13 @@ package components
import domainServer "github.com/haydenhargreaves/Potion/internal/domain/server"
import domainRecipe "github.com/haydenhargreaves/Potion/internal/domain/recipe"
-templ SearchBar(filters domainRecipe.SearchFilters, redirect bool, searchOnLoad bool) {
+templ SearchBar(filters domainRecipe.SearchFilters, redirect, searchOnLoad, favorites bool) {
")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -126,12 +154,12 @@ func filterButton() templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var5 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var5 == nil {
- templ_7745c5c3_Var5 = templ.NopComponent
+ templ_7745c5c3_Var6 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var6 == nil {
+ templ_7745c5c3_Var6 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, " ")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
diff --git a/internal/templates/pages/favorites.templ b/internal/templates/pages/favorites.templ
index 853262f..b40a7de 100644
--- a/internal/templates/pages/favorites.templ
+++ b/internal/templates/pages/favorites.templ
@@ -1,15 +1,66 @@
package templates
+import "fmt"
import "github.com/haydenhargreaves/Potion/internal/templates/components"
+import "github.com/haydenhargreaves/Potion/internal/domain/recipe"
+import domainServer "github.com/haydenhargreaves/Potion/internal/domain/server"
-templ FavoritesPage() {
-@components.Navbar("favorites")
-
-
-
-
Page Under Construction
-
Sit tight, this page is coming soon!
-
-
-
+templ favoriteList(recipes []domain.Recipe) {
+
+ for _, recipe := range recipes {
+ @searchResult(recipe)
+ }
+ if len(recipes) == 0 || recipes == nil {
+
No results
+ } else {
+
End of results
+ }
+
+}
+
+templ favoriteResult(recipe domain.Recipe) {
+
+
+
+
+ { recipe.Title } { recipe.Category }
+
+
+
+ @timeIconSm()
+ { recipe.Duration.Total } min
+
+
+ for _ = range(recipe.Difficulty) {
+ @starIconSm(true)
+ }
+ for _ = range(5 - recipe.Difficulty) {
+ @starIconSm(false)
+ }
+
+
+ @servingIconSm()
+ Serves { recipe.Serves }
+
+
+
{ recipe.Description }
+
+
+}
+
+templ FavoritesPage(filters domain.SearchFilters) {
+ @components.Navbar("favorites")
+
+
+ @components.BannerText("Favorites")
+ @components.SearchBar(filters, false, true, true)
+
+ @favoriteList(nil)
+
+
}
diff --git a/internal/templates/pages/favorites_templ.go b/internal/templates/pages/favorites_templ.go
index a09f819..fa4d692 100644
--- a/internal/templates/pages/favorites_templ.go
+++ b/internal/templates/pages/favorites_templ.go
@@ -8,9 +8,12 @@ package templates
import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"
+import "fmt"
import "github.com/haydenhargreaves/Potion/internal/templates/components"
+import "github.com/haydenhargreaves/Potion/internal/domain/recipe"
+import domainServer "github.com/haydenhargreaves/Potion/internal/domain/server"
-func FavoritesPage() templ.Component {
+func favoriteList(recipes []domain.Recipe) 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 {
@@ -31,11 +34,216 @@ func FavoritesPage() templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ for _, recipe := range recipes {
+ templ_7745c5c3_Err = searchResult(recipe).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ if len(recipes) == 0 || recipes == nil {
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "
No results
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ } else {
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "
End of results
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ return nil
+ })
+}
+
+func favoriteResult(recipe domain.Recipe) 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_Var2 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var2 == nil {
+ templ_7745c5c3_Var2 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var4 string
+ templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(recipe.Title)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/favorites.templ`, Line: 31, Col: 18}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " ")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var5 string
+ templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(recipe.Category)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/favorites.templ`, Line: 31, Col: 89}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, " ")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = timeIconSm().Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var6 string
+ templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(recipe.Duration.Total)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/favorites.templ`, Line: 36, Col: 28}
+ }
+ _, 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, 9, " min ")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ for _ = range recipe.Difficulty {
+ templ_7745c5c3_Err = starIconSm(true).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ for _ = range 5 - recipe.Difficulty {
+ templ_7745c5c3_Err = starIconSm(false).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, " ")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = servingIconSm().Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "Serves ")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var7 string
+ templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(recipe.Serves)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/favorites.templ`, Line: 48, Col: 27}
+ }
+ _, 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, "
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var8 string
+ templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(recipe.Description)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/favorites.templ`, Line: 51, Col: 72}
+ }
+ _, 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, "
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ return nil
+ })
+}
+
+func FavoritesPage(filters domain.SearchFilters) 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_Var9 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var9 == nil {
+ templ_7745c5c3_Var9 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = components.Navbar("favorites").Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "Page Under Construction Sit tight, this page is coming soon!
")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = components.BannerText("Favorites").Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = components.SearchBar(filters, false, true, true).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = favoriteList(nil).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
diff --git a/internal/templates/pages/home.templ b/internal/templates/pages/home.templ
index 09bf1c3..24ff670 100644
--- a/internal/templates/pages/home.templ
+++ b/internal/templates/pages/home.templ
@@ -5,106 +5,112 @@ import "github.com/haydenhargreaves/Potion/internal/domain/server"
import domainRecipe "github.com/haydenhargreaves/Potion/internal/domain/recipe"
templ introSection() {
-
-
-
-
-
-
- Discover Your Next Favorite Meal
-
-
-
- Welcome to your ultimate recipe hub! Whether you're a seasoned chef or just starting your culinary adventure,
- we're here to inspire. Explore thousands of delicious recipes, from quick weeknight dinners to gourmet delights,
- all at your fingertips. Find exactly what you're craving with our powerful search and intuitive filters, or
- browse our trending dishes for fresh ideas.
-
-
+
+
+
+
+
+
+ Discover Your Next Favorite Meal
+
+
+
+ Welcome to your ultimate recipe hub! Whether you're a seasoned chef or just starting your culinary adventure,
+ we're here to inspire. Explore thousands of delicious recipes, from quick weeknight dinners to gourmet delights,
+ all at your fingertips. Find exactly what you're craving with our powerful search and intuitive filters, or
+ browse our trending dishes for fresh ideas.
+
+
}
templ searchSection() {
-
- @components.BannerText("Craving Something Specific?")
-
- @components.SearchBar(domainRecipe.SearchFilters{}, true, false)
-
-
-
+
+ @components.BannerText("Craving Something Specific?")
+
+ @components.SearchBar(domainRecipe.SearchFilters{}, true, false, false)
+
+
+
}
templ highlightSection(liked bool) {
-
- @components.BannerText("Recipe of the Week!")
-
- Our 'Recipe of the Week' is the cream of the crop! We handpick it by looking at what recipes
- our community loves most. This isn't just about how many people view a recipe; it's also about
- how many times it's been made, liked, reviewed, and its average rating, all combined to find
- the true fan favorite of the week. It's our way of highlighting the best recipes that truly
- resonate with our users!
-
-
- @components.RecipeCardLarge(false)
-
-
+
+ @components.BannerText("Recipe of the Week!")
+
+ Our 'Recipe of the Week' is the cream of the crop! We handpick it by looking at what recipes
+ our community loves most. This isn't just about how many people view a recipe; it's also about
+ how many times it's been made, liked, reviewed, and its average rating, all combined to find
+ the true fan favorite of the week. It's our way of highlighting the best recipes that truly
+ resonate with our users!
+
+
+ @components.RecipeCardLarge(false)
+
+
}
templ listsSection() {
-
- @components.BannerText("Take Another Look.")
-
-
Recently viewed
-
- @components.RecipeCardSmall("Avocado Toast", "Breakfast - 15 min", "Hayden Hargreaves", true)
- @components.RecipeCardSmall("Fried Chicken", "Dinner - 120 min", "Hayden Hargreaves", false)
- @components.RecipeCardSmall("Classic Butter Chicken", "Dinner - 60 min", "Hayden Hargreaves", false)
- @components.RecipeCardSmall("Avocado Toast", "Breakfast - 15 min", "Hayden Hargreaves", true)
- @components.RecipeCardSmall("Fried Chicken", "Dinner - 120 min", "Hayden Hargreaves", false)
- @components.RecipeCardSmall("Classic Butter Chicken", "Dinner - 60 min", "Hayden Hargreaves", false)
-
-
Make again
-
- @components.RecipeCardSmall("Avocado Toast", "Breakfast - 15 min", "Hayden Hargreaves", true)
- @components.RecipeCardSmall("Fried Chicken", "Dinner - 120 min", "Hayden Hargreaves", false)
- @components.RecipeCardSmall("Classic Butter Chicken", "Dinner - 60 min", "Hayden Hargreaves", false)
- @components.RecipeCardSmall("Avocado Toast", "Breakfast - 15 min", "Hayden Hargreaves", true)
- @components.RecipeCardSmall("Fried Chicken", "Dinner - 120 min", "Hayden Hargreaves", false)
- @components.RecipeCardSmall("Classic Butter Chicken", "Dinner - 60 min", "Hayden Hargreaves", false)
-
-
-
+
+ @components.BannerText("Take Another Look.")
+
+
Recently viewed
+
+ @components.RecipeCardSmall("Avocado Toast", "Breakfast - 15 min", "Hayden Hargreaves", true)
+ @components.RecipeCardSmall("Fried Chicken", "Dinner - 120 min", "Hayden Hargreaves", false)
+ @components.RecipeCardSmall("Classic Butter Chicken", "Dinner - 60 min", "Hayden Hargreaves", false)
+ @components.RecipeCardSmall("Avocado Toast", "Breakfast - 15 min", "Hayden Hargreaves", true)
+ @components.RecipeCardSmall("Fried Chicken", "Dinner - 120 min", "Hayden Hargreaves", false)
+ @components.RecipeCardSmall("Classic Butter Chicken", "Dinner - 60 min", "Hayden Hargreaves", false)
+
+
Make again
+
+ @components.RecipeCardSmall("Avocado Toast", "Breakfast - 15 min", "Hayden Hargreaves", true)
+ @components.RecipeCardSmall("Fried Chicken", "Dinner - 120 min", "Hayden Hargreaves", false)
+ @components.RecipeCardSmall("Classic Butter Chicken", "Dinner - 60 min", "Hayden Hargreaves", false)
+ @components.RecipeCardSmall("Avocado Toast", "Breakfast - 15 min", "Hayden Hargreaves", true)
+ @components.RecipeCardSmall("Fried Chicken", "Dinner - 120 min", "Hayden Hargreaves", false)
+ @components.RecipeCardSmall("Classic Butter Chicken", "Dinner - 60 min", "Hayden Hargreaves", false)
+
+
+
}
templ ctaSection() {
-
+ text-lg md:text-2xl font-bold uppercase tracking-wide"
+ >
+ Create Your Recipe!
+
+
}
templ HomePage() {
-@components.Navbar("home")
-
-
- @introSection()
- @searchSection()
- @highlightSection(false)
- @listsSection()
- @ctaSection()
-
-
+ @components.Navbar("home")
+
+
+ @introSection()
+ @searchSection()
+ @highlightSection(false)
+ @listsSection()
+ @ctaSection()
+
+
}
diff --git a/internal/templates/pages/home_templ.go b/internal/templates/pages/home_templ.go
index 4e3c435..93a7dc5 100644
--- a/internal/templates/pages/home_templ.go
+++ b/internal/templates/pages/home_templ.go
@@ -74,7 +74,7 @@ func searchSection() templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = components.SearchBar(domainRecipe.SearchFilters{}, true, false).Render(ctx, templ_7745c5c3_Buffer)
+ templ_7745c5c3_Err = components.SearchBar(domainRecipe.SearchFilters{}, true, false, false).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
diff --git a/internal/templates/pages/profile.templ b/internal/templates/pages/profile.templ
index c53031e..e06cd14 100644
--- a/internal/templates/pages/profile.templ
+++ b/internal/templates/pages/profile.templ
@@ -9,190 +9,177 @@ import domainUser "github.com/haydenhargreaves/Potion/internal/domain/user"
import domainEngagement "github.com/haydenhargreaves/Potion/internal/domain/engagement"
func displayDifficulty(diff int) string {
- switch diff {
- case 1:
- return "Beginner"
- case 2:
- return "Easy"
- case 3:
- return "Intermediate"
- case 4:
- return "Challenging"
- case 5:
- return "Extreme"
- default:
- return ""
- }
+ switch diff {
+ case 1:
+ return "Beginner"
+ case 2:
+ return "Easy"
+ case 3:
+ return "Intermediate"
+ case 4:
+ return "Challenging"
+ case 5:
+ return "Extreme"
+ default:
+ return ""
+ }
}
func displayTags(tags []domainRecipe.Tag) string {
- names := make([]string, 0, len(tags))
- for _, tag := range tags {
- names = append(names, tag.Name)
- }
- return strings.Join(names, ", ")
+ names := make([]string, 0, len(tags))
+ for _, tag := range tags {
+ names = append(names, tag.Name)
+ }
+ return strings.Join(names, ", ")
}
-templ userDetailsSection(user domainUser.User, recipeCount int) {
-
-
- if user.ImageUrl != "" {
-
- } else {
-
- }
-
-
-
{ user.Name }
-
{ user.Email }
-
-
-
{ recipeCount } recipes
-
0 favorites
-
-
-
-
+templ userDetailsSection(user domainUser.User, recipeCount int, favoriteCount int) {
+
+
+ if user.ImageUrl != "" {
+
+ } else {
+
+ }
+
+
+
{ user.Name }
+
{ user.Email }
+
+
+
{ recipeCount } recipes
+
{ favoriteCount } favorites
+
+
+
+
}
templ recipesSection(recipes []domainRecipe.Recipe) {
-
- My Recipes
-
- if len(recipes) <= 4 {
- for _, recipe := range recipes {
- @recipeListItem(recipe)
- }
- } else {
- for _, recipe := range recipes[:4] {
- @recipeListItem(recipe)
- }
- }
-
-
- See all...
-
-
-
-
+
+ My Recipes
+
+ if len(recipes) <= 4 {
+ for _, recipe :=range recipes {
+ @recipeListItem(recipe)
+ }
+ } else {
+ for _, recipe :=range recipes[:4] {
+ @recipeListItem(recipe)
+ }
+ }
+
+
+ See all...
+
+
+
+
}
templ favoritesSection(recipes []domainRecipe.Recipe) {
-
- My Favorites
-
- if len(recipes) <= 4 {
- for _, recipe := range recipes {
- @recipeListItem(recipe)
- }
- } else {
- for _, recipe := range recipes[:4] {
- @recipeListItem(recipe)
- }
- }
-
-
- See all...
-
-
-
-
+
+ My Favorites
+
+ if len(recipes) <= 4 {
+ for _, recipe := range recipes {
+ @recipeListItem(recipe)
+ }
+ } else {
+ for _, recipe := range recipes[:4] {
+ @recipeListItem(recipe)
+ }
+ }
+
+
+ See all...
+
+
+
+
}
templ activitySection(engagement []domainEngagement.Engagement) {
-
- Recent Activity
- Activity section is under construction!
-
-
+
+ Recent Activity
+ Activity section is under construction!
+
+
}
templ recipeListItem(recipe domainRecipe.Recipe) {
-
-
- { recipe.Title }
-
-
- Difficulty: { displayDifficulty(recipe.Difficulty) }
- | Duration: { recipe.Duration.Total } min
- | Category: { recipe.Category }
-
-
- Difficulty: { displayDifficulty(recipe.Difficulty) }
-
-
- Duration: { recipe.Duration.Total } min
-
-
- Category: { recipe.Category }
-
- if len(recipe.Tags) > 0 {
-
- Tags: { displayTags(recipe.Tags) }
-
- }
-
+
+
+ { recipe.Title }
+
+
+ Difficulty: { displayDifficulty(recipe.Difficulty) }
+ | Duration: { recipe.Duration.Total } min
+ | Category: { recipe.Category }
+
+
+ Difficulty: { displayDifficulty(recipe.Difficulty) }
+
+
+ Duration: { recipe.Duration.Total } min
+
+
+ Category: { recipe.Category }
+
+ if len(recipe.Tags) > 0 {
+
+ Tags: { displayTags(recipe.Tags) }
+
+ }
+
}
templ activityListItem(engagement domainEngagement.Engagement) {
-
-
- { engagement.Message }
-
-
- { engagement.Created.Format("01/02/2006") }
-
-
+
+
+ { engagement.Message }
+
+
+ { engagement.Created.Format("01/02/2006") }
+
+
}
templ logoutSection() {
-
+
}
templ ProfilePage(user domainUser.User, recipes []domainRecipe.Recipe, favorites []domainRecipe.Recipe, engagement []domainEngagement.Engagement) {
- @components.Navbar(" profile")
-
-
- @userDetailsSection(user, len(recipes))
- @recipesSection(recipes)
- @favoritesSection(favorites)
- @activitySection(engagement)
- @logoutSection()
-
-
+@components.Navbar(" profile")
+
+
+ @userDetailsSection(user, len(recipes), len(favorites))
+ @recipesSection(recipes)
+ @favoritesSection(favorites)
+ @activitySection(engagement)
+ @logoutSection()
+
+
}
diff --git a/internal/templates/pages/profile_templ.go b/internal/templates/pages/profile_templ.go
index 0a05a97..16819ce 100644
--- a/internal/templates/pages/profile_templ.go
+++ b/internal/templates/pages/profile_templ.go
@@ -41,7 +41,7 @@ func displayTags(tags []domainRecipe.Tag) string {
return strings.Join(names, ", ")
}
-func userDetailsSection(user domainUser.User, recipeCount int) templ.Component {
+func userDetailsSection(user domainUser.User, recipeCount int, favoriteCount int) 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 {
@@ -72,9 +72,10 @@ func userDetailsSection(user domainUser.User, recipeCount int) templ.Component {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
- templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(user.ImageUrl)
+ templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(
+ user.ImageUrl)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 42, Col: 24}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 41, Col: 19}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
@@ -90,9 +91,11 @@ func userDetailsSection(user domainUser.User, recipeCount int) templ.Component {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
- templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("https://ui-avatars.com/api/?name=%s+%s&size=150", strings.Split(user.Name, " ")[0], strings.Split(user.Name, " ")[1]))
+ templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(
+ fmt.Sprintf("https://ui-avatars.com/api/?name=%s+%s&size=150", strings.Split(user.Name, " ")[0],
+ strings.Split(user.Name, " ")[1]))
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 47, Col: 141}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 45, Col: 40}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
@@ -110,7 +113,7 @@ func userDetailsSection(user domainUser.User, recipeCount int) templ.Component {
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(user.Name)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 52, Col: 62}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 49, Col: 65}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
@@ -123,7 +126,7 @@ func userDetailsSection(user domainUser.User, recipeCount int) templ.Component {
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(user.Email)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 53, Col: 47}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 50, Col: 50}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
if templ_7745c5c3_Err != nil {
@@ -136,13 +139,26 @@ func userDetailsSection(user domainUser.User, recipeCount int) templ.Component {
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(recipeCount)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 56, Col: 72}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 53, Col: 75}
}
_, 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, 9, " recipes0 favorites
")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " recipes")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var7 string
+ templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(favoriteCount)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 54, Col: 77}
+ }
+ _, 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, 10, " favorites
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -166,12 +182,12 @@ func recipesSection(recipes []domainRecipe.Recipe) templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var7 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var7 == nil {
- templ_7745c5c3_Var7 = templ.NopComponent
+ templ_7745c5c3_Var8 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var8 == nil {
+ templ_7745c5c3_Var8 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "My Recipes ")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "My Recipes ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -190,7 +206,7 @@ func recipesSection(recipes []domainRecipe.Recipe) templ.Component {
}
}
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "See all... ")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "See all... ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -214,12 +230,12 @@ func favoritesSection(recipes []domainRecipe.Recipe) templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var8 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var8 == nil {
- templ_7745c5c3_Var8 = templ.NopComponent
+ templ_7745c5c3_Var9 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var9 == nil {
+ templ_7745c5c3_Var9 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "My Favorites ")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "My Favorites ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -238,7 +254,16 @@ func favoritesSection(recipes []domainRecipe.Recipe) templ.Component {
}
}
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "See all... ")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "See all... ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -262,12 +287,12 @@ func activitySection(engagement []domainEngagement.Engagement) templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var9 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var9 == nil {
- templ_7745c5c3_Var9 = templ.NopComponent
+ templ_7745c5c3_Var11 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var11 == nil {
+ templ_7745c5c3_Var11 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "Recent Activity Activity section is under construction!
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -301,139 +326,139 @@ func recipeListItem(recipe domainRecipe.Recipe) templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var10 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var10 == nil {
- templ_7745c5c3_Var10 = templ.NopComponent
+ templ_7745c5c3_Var12 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var12 == nil {
+ templ_7745c5c3_Var12 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var12 string
- templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(recipe.Title)
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 139, Col: 17}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "
Difficulty: ")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, " | Duration: ")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "\" hx-trigger=\"click\" hx-swap=\"none\" class=\"text-base md:text-lg hover:text-blue-600 duration-100 cursor-pointer\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var14 string
- templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(recipe.Duration.Total)
+ templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(recipe.Title)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 143, Col: 66}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 129, Col: 18}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, " min | Category: ")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "
Difficulty: ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var15 string
- templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(recipe.Category)
+ templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(displayDifficulty(recipe.Difficulty))
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 144, Col: 60}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 132, Col: 82}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "
Difficulty: ")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, " | Duration: ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var16 string
- templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(displayDifficulty(recipe.Difficulty))
+ templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(recipe.Duration.Total)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 147, Col: 81}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 133, Col: 67}
}
_, 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, 22, "
Duration: ")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, " min | Category: ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var17 string
- templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(recipe.Duration.Total)
+ templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(recipe.Category)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 150, Col: 64}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 134, Col: 61}
}
_, 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, 23, " min
Category: ")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "
Difficulty: ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var18 string
- templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(recipe.Category)
+ templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(displayDifficulty(recipe.Difficulty))
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 153, Col: 58}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 137, Col: 82}
}
_, 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, 24, "
")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "
Duration: ")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var19 string
+ templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(recipe.Duration.Total)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 140, Col: 65}
+ }
+ _, 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, 25, " min
Category: ")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var20 string
+ templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(recipe.Category)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 143, Col: 59}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if len(recipe.Tags) > 0 {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "Tags: ")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "
Tags: ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- var templ_7745c5c3_Var19 string
- templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(displayTags(recipe.Tags))
+ var templ_7745c5c3_Var21 string
+ templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(displayTags(recipe.Tags))
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 157, Col: 36}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 147, Col: 36}
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "
")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, " ")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -457,38 +482,38 @@ func activityListItem(engagement domainEngagement.Engagement) templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var20 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var20 == nil {
- templ_7745c5c3_Var20 = templ.NopComponent
+ templ_7745c5c3_Var22 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var22 == nil {
+ templ_7745c5c3_Var22 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- var templ_7745c5c3_Var21 string
- templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(engagement.Message)
+ var templ_7745c5c3_Var23 string
+ templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(engagement.Message)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 168, Col: 23}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 157, Col: 24}
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "
")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- var templ_7745c5c3_Var22 string
- templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(engagement.Created.Format("01/02/2006"))
+ var templ_7745c5c3_Var24 string
+ templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(engagement.Created.Format("01/02/2006"))
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 171, Col: 44}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/profile.templ`, Line: 160, Col: 45}
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "
")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -512,21 +537,21 @@ func logoutSection() templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var23 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var23 == nil {
- templ_7745c5c3_Var23 = templ.NopComponent
+ templ_7745c5c3_Var25 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var25 == nil {
+ templ_7745c5c3_Var25 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "\" class=\"text-center border border-red-500 text-red-500 w-9/10 md:w-1/3 py-2 rounded-lg hover:cursor-pointer hover:bg-red-100 duration-300\">Logout")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -550,20 +575,20 @@ func ProfilePage(user domainUser.User, recipes []domainRecipe.Recipe, favorites
}()
}
ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var25 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var25 == nil {
- templ_7745c5c3_Var25 = templ.NopComponent
+ templ_7745c5c3_Var27 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var27 == nil {
+ templ_7745c5c3_Var27 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = components.Navbar(" profile").Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = userDetailsSection(user, len(recipes)).Render(ctx, templ_7745c5c3_Buffer)
+ templ_7745c5c3_Err = userDetailsSection(user, len(recipes), len(favorites)).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -583,7 +608,7 @@ func ProfilePage(user domainUser.User, recipes []domainRecipe.Recipe, favorites
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "
")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
diff --git a/internal/templates/pages/search.templ b/internal/templates/pages/search.templ
index 58606fd..f4f6ddd 100644
--- a/internal/templates/pages/search.templ
+++ b/internal/templates/pages/search.templ
@@ -16,7 +16,7 @@ templ SearchPage(filters domainRecipe.SearchFilters, searchOnLoad bool) {
bg-white flex flex-col items-center"
>
@components.BannerText("Recipe Search")
- @components.SearchBar(filters, false, searchOnLoad)
+ @components.SearchBar(filters, false, searchOnLoad, false)
@ResultList(nil)
@@ -38,9 +38,9 @@ templ ResultList(recipes []domain.Recipe) {
templ searchResult(recipe domain.Recipe) {
diff --git a/internal/templates/pages/search_templ.go b/internal/templates/pages/search_templ.go
index 4402b67..3b8f2bf 100644
--- a/internal/templates/pages/search_templ.go
+++ b/internal/templates/pages/search_templ.go
@@ -49,7 +49,7 @@ func SearchPage(filters domainRecipe.SearchFilters, searchOnLoad bool) templ.Com
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = components.SearchBar(filters, false, searchOnLoad).Render(ctx, templ_7745c5c3_Buffer)
+ templ_7745c5c3_Err = components.SearchBar(filters, false, searchOnLoad, false).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -147,7 +147,7 @@ func searchResult(recipe domain.Recipe) templ.Component {
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf(domainServer.API_ENGAGEMENT_VIEW, recipe.Id))
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/search.templ`, Line: 41, Col: 70}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/pages/search.templ`, Line: 41, Col: 68}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {