Fix rendering mocks

This commit is contained in:
Eli Ribble 2026-03-02 23:38:05 +00:00
parent a0eee3a95f
commit 87fe5ec2e5
No known key found for this signature in database
2 changed files with 13 additions and 7 deletions

View file

@ -52,13 +52,21 @@ func addMock(r chi.Router, path string, template string) {
}) })
r.Get(path, renderMock(template)) r.Get(path, renderMock(template))
} }
type contentMock struct {
Config contentConfig
DistrictName string
URLs ContentMockURLs
}
func renderMock(template_name string) http.HandlerFunc { func renderMock(template_name string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
code := chi.URLParam(r, "code") code := chi.URLParam(r, "code")
if code == "" { if code == "" {
code = "abc-123" code = "abc-123"
} }
data := ContentMock{ data := contentMock{
Config: newContentConfig(),
DistrictName: "Delta MVCD", DistrictName: "Delta MVCD",
URLs: ContentMockURLs{ URLs: ContentMockURLs{
Dispatch: "/mock/dispatch", Dispatch: "/mock/dispatch",
@ -83,12 +91,14 @@ func renderMock(template_name string) http.HandlerFunc {
} }
type contentMockList struct { type contentMockList struct {
Mocks []mock Config contentConfig
Mocks []mock
} }
func renderMockList(w http.ResponseWriter, r *http.Request) { func renderMockList(w http.ResponseWriter, r *http.Request) {
data := contentMockList{ data := contentMockList{
Mocks: mocks, Config: newContentConfig(),
Mocks: mocks,
} }
html.RenderOrError(w, "sync/mock/root.html", data) html.RenderOrError(w, "sync/mock/root.html", data)
} }

View file

@ -42,10 +42,6 @@ type ContentMockURLs struct {
SettingUser string SettingUser string
SettingUserAdd string SettingUserAdd string
} }
type ContentMock struct {
DistrictName string
URLs ContentMockURLs
}
type ContentReportDetail struct { type ContentReportDetail struct {
NextURL string NextURL string
UpdateURL string UpdateURL string