confirmation response template
This commit is contained in:
parent
9734d4abf6
commit
28a3ca3bb4
3 changed files with 9 additions and 2 deletions
8
main.go
8
main.go
|
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
)
|
||||
|
|
@ -10,6 +11,9 @@ import (
|
|||
//go:embed public
|
||||
var public embed.FS
|
||||
|
||||
//go:embed templates
|
||||
var templates embed.FS
|
||||
|
||||
func unwrap[T any](output T, err error) T {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -23,8 +27,10 @@ func handlePost(w http.ResponseWriter, r *http.Request) {
|
|||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println(r.Form)
|
||||
w.WriteHeader(http.StatusAccepted)
|
||||
fmt.Println(r.Form)
|
||||
tmpl, _ := template.ParseFS(templates, "templates/order/confirmation.html")
|
||||
_ = tmpl.Execute(w, struct{ Status string }{Status: "accepted"})
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<form x-show="open" hx-get="confirmation.html" hx-swap="outerHTML">
|
||||
<form x-show="open" hx-post="order/new" hx-swap="outerHTML">
|
||||
<div>
|
||||
<label for="firstname">First Name</label>
|
||||
<input type="text" id="firstname" name="firstname" value="">
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<div id="order_confirmation" hx-get="new_order.html" hx-swap="outerHTML">
|
||||
<button hx-get="new_order.html" hx-target="#order_confirmation" hx-swap="outerHTML" x-on:click="open = false">Back</button>
|
||||
<button hx-get="new_order.html" hx-target="#order_confirmation" hx-swap="outerHTML">New Order</button>
|
||||
{{.Status}}
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue