Do not panic is there is no home slogan yet

This commit is contained in:
jordi fita mas 2024-01-29 19:57:59 +01:00
parent 33100a6149
commit 036c3bc9ce
1 changed files with 5 additions and 1 deletions

View File

@ -53,7 +53,11 @@ func (p *homePage) MustRender(w http.ResponseWriter, r *http.Request, user *auth
p.CampsiteTypes = mustCollectCampsiteTypes(r.Context(), company, conn, user.Locale)
p.Cover = carousel.MustCollectSlides(r.Context(), company, conn, user.Locale, coverName)
p.Carousel = carousel.MustCollectSlides(r.Context(), company, conn, user.Locale, carouselName)
p.Slogan = conn.MustGetText(r.Context(), "select coalesce(i18n.slogan, home.slogan) from home left join camper.home_i18n as i18n on i18n.company_id = home.company_id and i18n.lang_tag = $1 where home.company_id = $2", user.Locale.Language, company.ID)
var err error
p.Slogan, err = conn.GetText(r.Context(), "select coalesce(i18n.slogan, home.slogan) from home left join camper.home_i18n as i18n on i18n.company_id = home.company_id and i18n.lang_tag = $1 where home.company_id = $2", user.Locale.Language, company.ID)
if err != nil && !database.ErrorIsNotFound(err) {
panic(err)
}
template.MustRenderPublic(w, r, user, company, "home.gohtml", p)
}