- Extract AssembleJuniors(ctx) from ServeJuniors JSON handler so HTML
and JSON share the same view-model path (mirrors AssembleAdults pattern)
- Add JuniorsPageData wrapper in render.go
- Wire HTMLHandler.ServeJuniors to AssembleJuniors + render template
- Replace 4-line placeholder juniors.tmpl with full template:
member table, name filter, month-range filter, totals row,
Credits + Debts sections, Pay / Pay All buttons via /qr links
(no Unmatched section — matches Python juniors.html parity)
- J/A attendance breakdown ("3/500 CZK (4:2J,1A)") and "?" sentinel
rendered via MonthCell.Text from buildJuniorMemberRow, no extra
template logic needed
- All tests pass; make parity reports 3/3 routes OK
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
61 lines
1.7 KiB
Go
61 lines
1.7 KiB
Go
package web
|
|
|
|
import (
|
|
"fuj-management/go/internal/web/api"
|
|
"net/http"
|
|
)
|
|
|
|
// HTMLHandler serves the Go-native HTML frontend.
|
|
type HTMLHandler struct {
|
|
renderer *Renderer
|
|
build BuildInfo
|
|
apiHandler *api.Handler
|
|
}
|
|
|
|
// NewHTMLHandler constructs an HTMLHandler.
|
|
func NewHTMLHandler(r *Renderer, b BuildInfo, ah *api.Handler) *HTMLHandler {
|
|
return &HTMLHandler{renderer: r, build: b, apiHandler: ah}
|
|
}
|
|
|
|
func (h *HTMLHandler) ServeAdults(w http.ResponseWriter, r *http.Request) {
|
|
data, err := h.apiHandler.AssembleAdults(r.Context())
|
|
if err != nil {
|
|
h.renderer.Render(w, "adults", AdultsPageData{
|
|
PageData: PageData{Active: "adults", Build: h.build},
|
|
Error: err.Error(),
|
|
})
|
|
return
|
|
}
|
|
h.renderer.Render(w, "adults", AdultsPageData{
|
|
PageData: PageData{Active: "adults", Build: h.build},
|
|
Data: data,
|
|
})
|
|
}
|
|
|
|
func (h *HTMLHandler) ServeJuniors(w http.ResponseWriter, r *http.Request) {
|
|
data, err := h.apiHandler.AssembleJuniors(r.Context())
|
|
if err != nil {
|
|
h.renderer.Render(w, "juniors", JuniorsPageData{
|
|
PageData: PageData{Active: "juniors", Build: h.build},
|
|
Error: err.Error(),
|
|
})
|
|
return
|
|
}
|
|
h.renderer.Render(w, "juniors", JuniorsPageData{
|
|
PageData: PageData{Active: "juniors", Build: h.build},
|
|
Data: data,
|
|
})
|
|
}
|
|
|
|
func (h *HTMLHandler) ServePayments(w http.ResponseWriter, r *http.Request) {
|
|
h.renderer.Render(w, "payments", PageData{Active: "payments", Build: h.build})
|
|
}
|
|
|
|
func (h *HTMLHandler) ServeSync(w http.ResponseWriter, r *http.Request) {
|
|
h.renderer.Render(w, "sync", PageData{Active: "sync", Build: h.build})
|
|
}
|
|
|
|
func (h *HTMLHandler) ServeFlushCache(w http.ResponseWriter, r *http.Request) {
|
|
h.renderer.Render(w, "flush_cache", PageData{Active: "flush", Build: h.build})
|
|
}
|