diff --git a/handlers/account.go b/handlers/account.go new file mode 100644 index 0000000..36c180f --- /dev/null +++ b/handlers/account.go @@ -0,0 +1,25 @@ +package handlers + +import ( + "net/http" + "projectreshoot/view/component/account" + "projectreshoot/view/page" +) + +func HandleAccountPage() http.Handler { + return http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + page.Account("General").Render(r.Context(), w) + }, + ) +} + +func HandleAccountSubpage() http.Handler { + return http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + r.ParseForm() + subpage := r.FormValue("subpage") + account.AccountContent(subpage).Render(r.Context(), w) + }, + ) +} diff --git a/handlers/profile.go b/handlers/profile.go index 91d21b2..91f381f 100644 --- a/handlers/profile.go +++ b/handlers/profile.go @@ -5,7 +5,7 @@ import ( "projectreshoot/view/page" ) -func HandleProfile() http.Handler { +func HandleProfilePage() http.Handler { return http.HandlerFunc( func(w http.ResponseWriter, r *http.Request) { page.Profile().Render(r.Context(), w) diff --git a/server/routes.go b/server/routes.go index 19c87f7..fc54841 100644 --- a/server/routes.go +++ b/server/routes.go @@ -63,6 +63,16 @@ func addRoutes( // Profile page mux.Handle("GET /profile", middleware.RequiresLogin( - handlers.HandleProfile(), + handlers.HandleProfilePage(), + )) + + // Account page + mux.Handle("GET /account", + middleware.RequiresLogin( + handlers.HandleAccountPage(), + )) + mux.Handle("POST /account-select-page", + middleware.RequiresLogin( + handlers.HandleAccountSubpage(), )) } diff --git a/view/component/account/content.templ b/view/component/account/content.templ new file mode 100644 index 0000000..2e84536 --- /dev/null +++ b/view/component/account/content.templ @@ -0,0 +1,15 @@ +package account + +templ AccountContent(subpage string) { +
+} diff --git a/view/component/account/selectmenu.templ b/view/component/account/selectmenu.templ new file mode 100644 index 0000000..c8c1ea9 --- /dev/null +++ b/view/component/account/selectmenu.templ @@ -0,0 +1,55 @@ +package account + +import "fmt" + +type MenuItem struct { + name string + href string +} + +func getMenuItems() []MenuItem { + return []MenuItem{ + { + name: "General", + href: "general", + }, + { + name: "Security", + href: "security", + }, + { + name: "Preferences", + href: "preferences", + }, + } +} + +templ SelectMenu(activePage string) { + {{ + menuItems := getMenuItems() + page := fmt.Sprintf("{page:'%s'}", activePage) + }} +