feat: Refactoring route declarations.

This commit is contained in:
2025-01-19 10:52:15 -05:00
parent d27a19863a
commit 1c8748211c
20 changed files with 954 additions and 644 deletions

View File

@@ -15,14 +15,15 @@ struct VendorDetail: HTML {
} closeButton: {
Button.close(id: "float")
.attributes(
.hx.get("/vendors"),
.hx.get(route: .vendor(.shared(.index(withBranches: true)))),
.hx.pushURL(true),
.hx.target("body"),
.hx.target(.body),
.hx.swap(.outerHTML)
)
}
}
// TODO: What route for here??
var branchForm: some HTML {
form(
.id("branch-form"),
@@ -33,7 +34,7 @@ struct VendorDetail: HTML {
) {
input(
.type(.text), .class("col-9"), .name("name"), .placeholder("Add branch..."), .required,
.hx.post("/vendors/\(vendor.id)/branches"),
.hx.post(route: .vendorBranch(.index(for: vendor.id))),
.hx.trigger(.event(.keyup).changed().delay("800ms")),
.hx.target("#branches"),
.hx.swap(.beforeEnd) // ,
@@ -65,7 +66,7 @@ struct VendorDetail: HTML {
span(.class("label")) { branch.name.capitalized }
button(
.class("btn"),
.hx.delete("/api/v1/vendors/branches/\(branch.id)"),
.hx.delete(route: .vendorBranch(.delete(id: branch.id))),
.hx.target("#branch_\(branch.id)"),
.hx.swap(.outerHTML.transition(true).swap("0.5s"))
) {