diff --git a/pkg/template/page.go b/pkg/template/page.go index fa2896c..2264573 100644 --- a/pkg/template/page.go +++ b/pkg/template/page.go @@ -54,7 +54,7 @@ func (p *PublicPage) Setup(r *http.Request, user *auth.User, company *auth.Compa `, user.Locale.Language, company.ID), } - if err := p.CompanyAddress.FillFromDatabase(r.Context(), conn, company); err != nil { + if err := p.CompanyAddress.FillFromDatabase(r.Context(), conn, user, company); err != nil { panic(err) } } @@ -105,30 +105,35 @@ type address struct { PostalCode string Province string City string + Country string Phone string Email string RTCNumber string } -func (addr *address) FillFromDatabase(ctx context.Context, conn *database.Conn, company *auth.Company) error { +func (addr *address) FillFromDatabase(ctx context.Context, conn *database.Conn, user *auth.User, company *auth.Company) error { row := conn.QueryRow(ctx, ` select trade_name , address , postal_code , province , city + , coalesce(country_i18n.name, country.name) as country_name , phone::text , email::text , rtc_number from company + join country using (country_code) + left join country_i18n on country.country_code = country_i18n.country_code and country_i18n.lang_tag = $2 where company_id = $1 -`, company.ID) +`, company.ID, user.Locale.Language) return row.Scan( &addr.TradeName, &addr.Address, &addr.PostalCode, &addr.Province, &addr.City, + &addr.Country, &addr.Phone, &addr.Email, &addr.RTCNumber, diff --git a/web/templates/public/layout.gohtml b/web/templates/public/layout.gohtml index 3616f9e..1edec33 100644 --- a/web/templates/public/layout.gohtml +++ b/web/templates/public/layout.gohtml @@ -114,6 +114,7 @@
{{ .Address }}
{{ .PostalCode}} · {{ .City }} · {{ .Province }}
+ {{ .Country }}
T {{ .Phone }}
{{ .Email }}