feat: Working on adding updates to project form, it's currently not loading an existing project.

This commit is contained in:
2026-01-05 17:04:25 -05:00
parent 4c8a23be94
commit fc12e47b5c
9 changed files with 178 additions and 35 deletions

View File

@@ -21,9 +21,16 @@ struct ProjectForm: HTML, Sendable {
h1(.class("text-3xl font-bold pb-6 ps-2")) { "Project" }
form(
.class("space-y-4 p-4"),
.method(.post),
.action(route: .project(.index))
project == nil
? .hx.post(route: .project(.index))
: .hx.patch(route: .project(.index)),
.hx.target("body"),
.hx.swap(.outerHTML)
) {
if let project {
input(.class("hidden"), .name("id"), .value("\(project.id)"))
}
div {
label(.for("name")) { "Name" }
Input(id: "name", placeholder: "Name")
@@ -32,35 +39,32 @@ struct ProjectForm: HTML, Sendable {
div {
label(.for("streetAddress")) { "Address" }
Input(id: "streetAddress", placeholder: "Street Address")
.attributes(.type(.text), .required)
.attributes(.type(.text), .required, .value(project?.streetAddress))
}
div {
label(.for("city")) { "City" }
Input(id: "city", placeholder: "City")
.attributes(.type(.text), .required)
.attributes(.type(.text), .required, .value(project?.city))
}
div {
label(.for("state")) { "State" }
Input(id: "state", placeholder: "State")
.attributes(.type(.text), .required)
.attributes(.type(.text), .required, .value(project?.state))
}
div {
label(.for("zipCode")) { "Zip" }
Input(id: "zipCode", placeholder: "Zip code")
.attributes(.type(.text), .required)
.attributes(.type(.text), .required, .value(project?.zipCode))
}
Row {
div {}
div(.class("space-x-4")) {
CancelButton()
.attributes(
.hx.get(route: .project(.form(dismiss: true))),
.hx.target("#projectForm"),
.hx.swap(.outerHTML)
)
SubmitButton()
}
div(.class("flex justify-end space-x-6")) {
CancelButton()
.attributes(
.hx.get(route: .project(.form(dismiss: true))),
.hx.target("#projectForm"),
.hx.swap(.outerHTML)
)
SubmitButton()
}
}
}