admin page updates
This commit is contained in:
@@ -14,10 +14,20 @@ import (
|
||||
// AdminUsersPage renders the full admin dashboard page with users section
|
||||
func AdminUsersPage(s *hws.Server, conn *bun.DB) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
var pageOpts *db.PageOpts
|
||||
if r.Method == "GET" {
|
||||
pageOpts = pageOptsFromQuery(s, w, r)
|
||||
} else {
|
||||
pageOpts = pageOptsFromForm(s, w, r)
|
||||
}
|
||||
if pageOpts == nil {
|
||||
return
|
||||
}
|
||||
|
||||
var users *db.List[db.User]
|
||||
if ok := db.WithReadTx(s, w, r, conn, func(ctx context.Context, tx bun.Tx) (bool, error) {
|
||||
var err error
|
||||
users, err = db.GetUsersWithRoles(ctx, tx, nil)
|
||||
users, err = db.GetUsersWithRoles(ctx, tx, pageOpts)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "db.GetUsersWithRoles")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user