feat: Adds api route tests. Tested user interface works as expected, still needs some work on vendors form.
This commit is contained in:
@@ -26,15 +26,15 @@ struct VendorDetail: HTML {
|
||||
|
||||
// TODO: What route for here??
|
||||
var branchForm: some HTML {
|
||||
// TODO: Add hidden input field with vendor id.
|
||||
form(
|
||||
.id("branch-form"),
|
||||
.hx.post("/vendors/\(vendor.id)/branches"),
|
||||
.id(.branch(.form)),
|
||||
.hx.post("/vendors/branches"),
|
||||
.hx.target("#branches"),
|
||||
.hx.swap(.beforeEnd),
|
||||
.hx.on(.afterRequest, .ifSuccessful(.resetForm))
|
||||
// .custom(name: "hx-on::after-request", value: "if(event.detail.successful) this.reset();")
|
||||
) {
|
||||
input(.type(.hidden), .name("vendorID"), .value(vendor.id.uuidString))
|
||||
input(
|
||||
.type(.text), .class("col-9"), .name("name"), .placeholder("Add branch..."), .required,
|
||||
// FIX: route
|
||||
|
||||
@@ -40,7 +40,7 @@ struct VendorForm: HTML {
|
||||
|
||||
func makeForm(vendor: Vendor?) -> some HTML {
|
||||
form(
|
||||
.id("vendor-form"),
|
||||
.id(.vendor(.form)),
|
||||
vendor != nil ? .hx.put(route: targetURL) : .hx.post(route: targetURL),
|
||||
.hx.target("#content"),
|
||||
.hx.swap(.outerHTML)
|
||||
@@ -63,7 +63,7 @@ struct VendorForm: HTML {
|
||||
.style("font-size: 1.25em; padding: 10px 20px; border-radius: 10px;"),
|
||||
.hx.delete(route: .vendor(.delete(id: vendor.id))),
|
||||
.hx.confirm("Are you sure you want to delete this vendor?"),
|
||||
.hx.target("#vendor_\(vendor.id)"),
|
||||
.hx.target(.id(.vendor(.row(id: vendor.id)))),
|
||||
.hx.swap(.outerHTML.transition(true).swap("1s")),
|
||||
.custom(
|
||||
name: "hx-on::after-request",
|
||||
|
||||
Reference in New Issue
Block a user