htmgo/partials/patient/create.go

32 lines
671 B
Go
Raw Normal View History

2024-09-11 21:08:35 +00:00
package patient
import (
"github.com/gofiber/fiber/v2"
"github.com/google/uuid"
"mhtml/database"
"mhtml/h"
"mhtml/partials/sheet"
"time"
)
func Create(ctx *fiber.Ctx) *h.Partial {
name := ctx.FormValue("name")
reason := ctx.FormValue("reason-for-visit")
location := ctx.FormValue("location-name")
database.HSet("patients", uuid.New().String(), Patient{
Name: name,
ReasonForVisit: reason,
AppointmentDate: time.Now(),
LocationName: location,
})
2024-09-12 02:06:34 +00:00
headers := h.CombineHeaders(h.PushQsHeader(ctx, "adding", ""), &map[string]string{
2024-09-11 21:08:35 +00:00
"HX-Trigger": "patient-added",
2024-09-12 02:06:34 +00:00
})
2024-09-11 21:08:35 +00:00
2024-09-12 02:06:34 +00:00
return h.NewPartialWithHeaders(
headers,
sheet.Close(ctx))
2024-09-11 21:08:35 +00:00
}