Now we have a working version without any JS. Way easier to do because javascript form submit blows hot wads.

This commit is contained in:
Zed A. Shaw 2025-07-27 01:44:45 -04:00
parent 3fd8169d83
commit 504433502a
3 changed files with 33 additions and 21 deletions

View file

@ -3,8 +3,6 @@ package admin
import (
"maps"
"strconv"
"fmt"
"reflect"
"github.com/gofiber/fiber/v2"
"zedshaw.games/webapp/data"
. "zedshaw.games/webapp/common"
@ -61,14 +59,16 @@ func GetPageSelectOne(c *fiber.Ctx) error {
}
func PostApiUpdate(c *fiber.Ctx) error {
user, err := ReceivePost[data.User](c)
if err != nil { return IfErrNil(err, c) }
fmt.Println("post received", user)
table := c.Params("table")
err = Update(c.Params("table"), reflect.ValueOf(user).Elem())
typeOf := data.Models()[table]
obj, err := ReflectOnPost(typeOf, c)
if err != nil { return IfErrNil(err, c) }
return c.JSON(fiber.Map{"status": "ok"})
err = Update(table, obj.Elem())
if err != nil { return IfErrNil(err, c) }
return c.RedirectBack("/admin/table/", 303)
}
func PutApiInsert(c *fiber.Ctx) error {