All checks were successful
Deploy to K8s / deploy (push) Successful in 6s
- Extract AssemblePayments(ctx) from ServePayments in api/handler.go, mirroring the AssembleAdults/AssembleJuniors pattern - Add PaymentsPageData view-model wrapper in render.go - Rewire html_handler.go ServePayments to call AssemblePayments and render with PaymentsPageData - Replace payments.tmpl placeholder with real grouped-by-person ledger: alphabetical member blocks, txn-table (Date/Amount/Purpose/Message), newest-first rows, Unmatched/Unknown bucket - Append ledger CSS classes to app.css (.ledger-container, .member-block, .txn-table, .txn-date/amount/purpose/message, tr:hover) - Add TestPaymentsPage markup test Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
72 lines
2.0 KiB
Go
72 lines
2.0 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) {
|
|
data, err := h.apiHandler.AssemblePayments(r.Context())
|
|
if err != nil {
|
|
h.renderer.Render(w, "payments", PaymentsPageData{
|
|
PageData: PageData{Active: "payments", Build: h.build},
|
|
Error: err.Error(),
|
|
})
|
|
return
|
|
}
|
|
h.renderer.Render(w, "payments", PaymentsPageData{
|
|
PageData: PageData{Active: "payments", Build: h.build},
|
|
Data: data,
|
|
})
|
|
}
|
|
|
|
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})
|
|
}
|