(FIX): Working on the nil derefs, removed tx's from select queries. #37
@ -58,7 +58,18 @@ func HomePage(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
page = templates.HomePage(true, viewedRecipes, madeRecipes, recipeOfTheWeek)
|
||||
if bytes, err := ctx.Cookie("search-filters"); err != nil {
|
||||
fmt.Printf("ERROR: Failed to get search-filter cookie. %s\n", err.Error())
|
||||
page = templates.HomePage(true, viewedRecipes, madeRecipes, recipeOfTheWeek, nil)
|
||||
} 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 = templates.HomePage(true, viewedRecipes, madeRecipes, recipeOfTheWeek, nil)
|
||||
} else {
|
||||
page = templates.HomePage(true, viewedRecipes, madeRecipes, recipeOfTheWeek, &filters)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Get the recipe of the week
|
||||
recipeOfTheWeek, err := deps.RecipeService.GetRecipeOfTheWeek(nil)
|
||||
@ -70,7 +81,18 @@ func HomePage(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
page = templates.HomePage(false, nil, nil, recipeOfTheWeek)
|
||||
if bytes, err := ctx.Cookie("search-filters"); err != nil {
|
||||
fmt.Printf("ERROR: Failed to get search-filter cookie. %s\n", err.Error())
|
||||
page = templates.HomePage(false, nil, nil, recipeOfTheWeek, nil)
|
||||
} 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 = templates.HomePage(false, nil, nil, recipeOfTheWeek, nil)
|
||||
} else {
|
||||
page = templates.HomePage(false, nil, nil, recipeOfTheWeek, &filters)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
title := "Potion - Home"
|
||||
|
||||
@ -10,10 +10,8 @@ templ introSection() {
|
||||
<video class="" autoplay loop muted playsinline>
|
||||
<source src="/v1/web/static/img/salmon_video.mp4" type="video/mp4" />
|
||||
</video>
|
||||
<h1
|
||||
class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-center
|
||||
text-white text-3xl w-4/5 font-bold z-10"
|
||||
>
|
||||
<h1 class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-center
|
||||
text-white text-3xl w-4/5 font-bold z-10">
|
||||
Discover Your Next Favorite Meal
|
||||
</h1>
|
||||
</div>
|
||||
@ -26,11 +24,11 @@ templ introSection() {
|
||||
</section>
|
||||
}
|
||||
|
||||
templ searchSection() {
|
||||
templ searchSection(filters *domainRecipe.SearchFilters) {
|
||||
<section class="w-full flex flex-col items-center justify-center my-8 py-4">
|
||||
@components.BannerText("Craving Something Specific?")
|
||||
<div class="w-full md:w-3/4">
|
||||
@components.SearchBar(nil, true, false, false)
|
||||
@components.SearchBar(filters, true, false, false)
|
||||
</div>
|
||||
<div class="hidden" id="result-list"></div>
|
||||
</section>
|
||||
@ -100,8 +98,7 @@ templ listsSection(loggedIn bool, viewed, made []domainRecipe.Recipe) {
|
||||
|
||||
templ ctaSection() {
|
||||
<section
|
||||
class="w-full flex flex-col items-center justify-center mt-16 py-8 md:py-12 bg-gradient-to-br from-blue-100 to-purple-100 text-center"
|
||||
>
|
||||
class="w-full flex flex-col items-center justify-center mt-16 py-8 md:py-12 bg-gradient-to-br from-blue-100 to-purple-100 text-center">
|
||||
<h2 class="text-2xl md:text-3xl font-extrabold text-gray-800 mb-6 px-4">
|
||||
Unleash Your Inner Chef!
|
||||
</h2>
|
||||
@ -109,25 +106,22 @@ templ ctaSection() {
|
||||
Have a unique recipe idea? Want to share your culinary masterpiece with the world?
|
||||
It's time to bring your creations to life!
|
||||
</p>
|
||||
<a
|
||||
href={ domain.WEB_CREATE }
|
||||
class="flex items-center justify-center
|
||||
<a href={ domain.WEB_CREATE } class="flex items-center justify-center
|
||||
bg-gradient-to-r from-blue-400 to-blue-600 text-white
|
||||
px-12 py-5 rounded-full shadow-sm hover:shadow-md
|
||||
transition-all duration-300 ease-in-out shadow-blue-700
|
||||
text-lg md:text-2xl font-bold uppercase tracking-wide"
|
||||
>
|
||||
text-lg md:text-2xl font-bold uppercase tracking-wide">
|
||||
Create Your Recipe!
|
||||
</a>
|
||||
</section>
|
||||
}
|
||||
|
||||
templ HomePage(loggedIn bool, viewed, made []domainRecipe.Recipe, recipeOfTheWeek *domainRecipe.Recipe) {
|
||||
templ HomePage(loggedIn bool, viewed, made []domainRecipe.Recipe, recipeOfTheWeek *domainRecipe.Recipe, filters *domainRecipe.SearchFilters) {
|
||||
@components.Navbar("home")
|
||||
<div class="w-full h-fit flex justify-center">
|
||||
<div class="mx-2 md:mx-0 w-full md:w-1/2 md:pt-14 h-full border-l border-r border-gray-300 bg-white">
|
||||
@introSection()
|
||||
@searchSection()
|
||||
@searchSection(filters)
|
||||
@highlightSection(recipeOfTheWeek)
|
||||
@listsSection(loggedIn, viewed, made)
|
||||
@ctaSection()
|
||||
|
||||
@ -41,7 +41,7 @@ func introSection() templ.Component {
|
||||
})
|
||||
}
|
||||
|
||||
func searchSection() templ.Component {
|
||||
func searchSection(filters *domainRecipe.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 {
|
||||
@ -74,7 +74,7 @@ func searchSection() templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = components.SearchBar(nil, true, false, false).Render(ctx, templ_7745c5c3_Buffer)
|
||||
templ_7745c5c3_Err = components.SearchBar(filters, true, false, false).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@ -304,7 +304,7 @@ func ctaSection() templ.Component {
|
||||
})
|
||||
}
|
||||
|
||||
func HomePage(loggedIn bool, viewed, made []domainRecipe.Recipe, recipeOfTheWeek *domainRecipe.Recipe) templ.Component {
|
||||
func HomePage(loggedIn bool, viewed, made []domainRecipe.Recipe, recipeOfTheWeek *domainRecipe.Recipe, filters *domainRecipe.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 {
|
||||
@ -337,7 +337,7 @@ func HomePage(loggedIn bool, viewed, made []domainRecipe.Recipe, recipeOfTheWeek
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = searchSection().Render(ctx, templ_7745c5c3_Buffer)
|
||||
templ_7745c5c3_Err = searchSection(filters).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user