Remove now-unused locales field from admin handlers

This commit is contained in:
jordi fita mas 2024-01-15 22:47:16 +01:00
parent 50bcbf012f
commit 8205bec34d
8 changed files with 17 additions and 29 deletions

View File

@ -16,7 +16,6 @@ import (
"dev.tandem.ws/tandem/camper/pkg/home" "dev.tandem.ws/tandem/camper/pkg/home"
httplib "dev.tandem.ws/tandem/camper/pkg/http" httplib "dev.tandem.ws/tandem/camper/pkg/http"
"dev.tandem.ws/tandem/camper/pkg/legal" "dev.tandem.ws/tandem/camper/pkg/legal"
"dev.tandem.ws/tandem/camper/pkg/locale"
"dev.tandem.ws/tandem/camper/pkg/location" "dev.tandem.ws/tandem/camper/pkg/location"
"dev.tandem.ws/tandem/camper/pkg/media" "dev.tandem.ws/tandem/camper/pkg/media"
"dev.tandem.ws/tandem/camper/pkg/season" "dev.tandem.ws/tandem/camper/pkg/season"
@ -36,17 +35,17 @@ type adminHandler struct {
services *services.AdminHandler services *services.AdminHandler
} }
func newAdminHandler(locales locale.Locales, mediaDir string) *adminHandler { func newAdminHandler(mediaDir string) *adminHandler {
return &adminHandler{ return &adminHandler{
campsite: campsite.NewAdminHandler(locales), campsite: campsite.NewAdminHandler(),
company: company.NewAdminHandler(), company: company.NewAdminHandler(),
home: home.NewAdminHandler(locales), home: home.NewAdminHandler(),
legal: legal.NewAdminHandler(), legal: legal.NewAdminHandler(),
location: location.NewAdminHandler(), location: location.NewAdminHandler(),
media: media.NewAdminHandler(mediaDir), media: media.NewAdminHandler(mediaDir),
payment: booking.NewAdminHandler(), payment: booking.NewAdminHandler(),
season: season.NewAdminHandler(locales), season: season.NewAdminHandler(),
services: services.NewAdminHandler(locales), services: services.NewAdminHandler(),
} }
} }

View File

@ -48,7 +48,7 @@ func New(db *database.DB, avatarsDir string, mediaDir string) (http.Handler, err
db: db, db: db,
fileHandler: static, fileHandler: static,
profile: profile, profile: profile,
admin: newAdminHandler(locales, mediaDir), admin: newAdminHandler(mediaDir),
public: newPublicHandler(), public: newPublicHandler(),
media: mediaHandler, media: mediaHandler,
locales: locales, locales: locales,

View File

@ -22,9 +22,9 @@ type AdminHandler struct {
types *types.AdminHandler types *types.AdminHandler
} }
func NewAdminHandler(locales locale.Locales) *AdminHandler { func NewAdminHandler() *AdminHandler {
return &AdminHandler{ return &AdminHandler{
types: types.NewAdminHandler(locales), types: types.NewAdminHandler(),
} }
} }

View File

@ -22,11 +22,10 @@ import (
) )
type AdminHandler struct { type AdminHandler struct {
locales locale.Locales
} }
func NewAdminHandler(locales locale.Locales) *AdminHandler { func NewAdminHandler() *AdminHandler {
return &AdminHandler{locales} return &AdminHandler{}
} }
func (h *AdminHandler) Handler(user *auth.User, company *auth.Company, conn *database.Conn) http.Handler { func (h *AdminHandler) Handler(user *auth.User, company *auth.Company, conn *database.Conn) http.Handler {

View File

@ -24,16 +24,14 @@ import (
type AdminHandler struct { type AdminHandler struct {
name string name string
indexHandler IndexHandler indexHandler IndexHandler
locales locale.Locales
} }
type IndexHandler func(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn) type IndexHandler func(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn)
func NewAdminHandler(name string, indexHandler IndexHandler, locales locale.Locales) *AdminHandler { func NewAdminHandler(name string, indexHandler IndexHandler) *AdminHandler {
return &AdminHandler{ return &AdminHandler{
name: name, name: name,
indexHandler: indexHandler, indexHandler: indexHandler,
locales: locales,
} }
} }

View File

@ -12,21 +12,18 @@ import (
"dev.tandem.ws/tandem/camper/pkg/carousel" "dev.tandem.ws/tandem/camper/pkg/carousel"
"dev.tandem.ws/tandem/camper/pkg/database" "dev.tandem.ws/tandem/camper/pkg/database"
httplib "dev.tandem.ws/tandem/camper/pkg/http" httplib "dev.tandem.ws/tandem/camper/pkg/http"
"dev.tandem.ws/tandem/camper/pkg/locale"
"dev.tandem.ws/tandem/camper/pkg/template" "dev.tandem.ws/tandem/camper/pkg/template"
) )
const carouselName = "home" const carouselName = "home"
type AdminHandler struct { type AdminHandler struct {
locales locale.Locales
carousel *carousel.AdminHandler carousel *carousel.AdminHandler
} }
func NewAdminHandler(locales locale.Locales) *AdminHandler { func NewAdminHandler() *AdminHandler {
return &AdminHandler{ return &AdminHandler{
locales: locales, carousel: carousel.NewAdminHandler(carouselName, serveHomeIndex),
carousel: carousel.NewAdminHandler(carouselName, serveHomeIndex, locales),
} }
} }

View File

@ -29,13 +29,10 @@ import (
const UnsetColor = 0xd1d0df const UnsetColor = 0xd1d0df
type AdminHandler struct { type AdminHandler struct {
locales locale.Locales
} }
func NewAdminHandler(locales locale.Locales) *AdminHandler { func NewAdminHandler() *AdminHandler {
return &AdminHandler{ return &AdminHandler{}
locales: locales,
}
} }
func (h *AdminHandler) Handler(user *auth.User, company *auth.Company, conn *database.Conn) http.HandlerFunc { func (h *AdminHandler) Handler(user *auth.User, company *auth.Company, conn *database.Conn) http.HandlerFunc {

View File

@ -24,14 +24,12 @@ import (
const carouselName = "services" const carouselName = "services"
type AdminHandler struct { type AdminHandler struct {
locales locale.Locales
carousel *carousel.AdminHandler carousel *carousel.AdminHandler
} }
func NewAdminHandler(locales locale.Locales) *AdminHandler { func NewAdminHandler() *AdminHandler {
return &AdminHandler{ return &AdminHandler{
locales: locales, carousel: carousel.NewAdminHandler(carouselName, serveServicesIndex),
carousel: carousel.NewAdminHandler(carouselName, serveServicesIndex, locales),
} }
} }