diff --git a/internal/app/handlers/engagement_handler.go b/internal/app/handlers/engagement_handler.go index dcca6d5..1f80b7b 100644 --- a/internal/app/handlers/engagement_handler.go +++ b/internal/app/handlers/engagement_handler.go @@ -1,6 +1,7 @@ package handlers import ( + "fmt" "net/http" "strconv" @@ -19,7 +20,8 @@ func EngagementViewRecipe(ctx *gin.Context) { "message": err.Error(), }) } else { - ctx.Status(http.StatusNoContent) + ctx.Header("HX-Redirect", fmt.Sprintf(domain.WEB_RECIPE, recipeId)) + ctx.Status(http.StatusOK) } return } @@ -32,7 +34,8 @@ func EngagementViewRecipe(ctx *gin.Context) { "message": err.Error(), }) } else { - ctx.Status(http.StatusNoContent) + ctx.Header("HX-Redirect", fmt.Sprintf(domain.WEB_RECIPE, recipeId)) + ctx.Status(http.StatusOK) } } diff --git a/internal/app/handlers/page_handler.go b/internal/app/handlers/page_handler.go index 3b36eb4..cadcee1 100644 --- a/internal/app/handlers/page_handler.go +++ b/internal/app/handlers/page_handler.go @@ -129,19 +129,20 @@ func RecipePage(ctx *gin.Context) { } // Add engagement - if loggedIn { - if _, err = deps.EngagementService.UserViewRecipe(*userId, recipe.Id); err != nil { - fmt.Printf("ERROR: %s\n", err.Error()) - ctx.JSON(400, err.Error()) - return - } - } else { - if _, err = deps.EngagementService.ViewRecipe(recipe.Id); err != nil { - fmt.Printf("ERROR: %s\n", err.Error()) - ctx.JSON(400, err.Error()) - return - } - } + // BUG: Don't want to do this here + // if loggedIn { + // if _, err = deps.EngagementService.UserViewRecipe(*userId, recipe.Id); err != nil { + // fmt.Printf("ERROR: %s\n", err.Error()) + // ctx.JSON(400, err.Error()) + // return + // } + // } else { + // if _, err = deps.EngagementService.ViewRecipe(recipe.Id); err != nil { + // fmt.Printf("ERROR: %s\n", err.Error()) + // ctx.JSON(400, err.Error()) + // return + // } + // } title := "Potion - View Recipe" page := pages.RecipePage(*recipe, *user, loggedIn) diff --git a/internal/app/service/recipe_service.go b/internal/app/service/recipe_service.go index 0f5a68b..be4ba73 100644 --- a/internal/app/service/recipe_service.go +++ b/internal/app/service/recipe_service.go @@ -33,7 +33,7 @@ func NewRecipeService(recipeRepository domain.RecipeRepository) domain.RecipeSer // occur. // // TODO: Implement validation in the API. -// TODO: Implement image creation and tag creation. +// TODO: Implement image creation. func (s *RecipeService) CreateRecipe(ctx *gin.Context) (*domain.Recipe, error) { // Ensure user is logged in if !domainServer.IsLoggedIn(ctx) { @@ -110,7 +110,7 @@ func (s *RecipeService) CreateRecipe(ctx *gin.Context) (*domain.Recipe, error) { if image != nil { } - // TODO: Create the tags in the database + // Create the tags if len(tags) > 0 { if err := s.recipeRepository.CreateRecipeTags(recipe, tags); err != nil { return &recipe, fmt.Errorf("Failed to attach/create tags. %s\n", err.Error()) diff --git a/internal/infrastructure/database/repository/recipe_repository.go b/internal/infrastructure/database/repository/recipe_repository.go index da5c6f7..a0a578d 100644 --- a/internal/infrastructure/database/repository/recipe_repository.go +++ b/internal/infrastructure/database/repository/recipe_repository.go @@ -251,8 +251,6 @@ func (r *RecipeRepository) SearchRecipes(filters domain.SearchFilters) ([]domain } } - // TODO: Title search somehow... - // Merge condition strings mealString := fmt.Sprintf("(%s)", strings.Join(mealConditions, " OR ")) timeString := fmt.Sprintf("(%s)", strings.Join(timeConditions, " OR ")) diff --git a/internal/templates/pages/profile.templ b/internal/templates/pages/profile.templ index 1dcf8a2..c13d33e 100644 --- a/internal/templates/pages/profile.templ +++ b/internal/templates/pages/profile.templ @@ -44,8 +44,7 @@ templ userDetailsSection(user domainUser.User, recipeCount int) { } else { }
@@ -67,7 +66,7 @@ templ recipesSection(recipes []domainRecipe.Recipe) {

My Recipes