feat: Updates form routes and database routes to use id's in the url path.

This commit is contained in:
2026-01-09 09:25:37 -05:00
parent 9356ccb1c9
commit 30fddb9dce
27 changed files with 677 additions and 322 deletions

View File

@@ -157,14 +157,14 @@ struct EffectiveLengthForm: HTML, Sendable {
let stepTwo: SiteRoute.View.ProjectRoute.EquivalentLengthRoute.StepTwo
var route: String {
if effectiveLength != nil {
return SiteRoute.View.router.path(
for: .project(.detail(projectID, .equivalentLength(.index))))
let baseRoute = SiteRoute.View.router.path(
for: .project(.detail(projectID, .equivalentLength(.index)))
)
if let effectiveLength {
return baseRoute.appendingPath(effectiveLength.id)
} else {
let baseRoute = SiteRoute.View.router.path(
for: .project(.detail(projectID, .equivalentLength(.index)))
)
return "\(baseRoute)/stepThree"
return baseRoute.appendingPath("stepThree")
}
}

View File

@@ -126,20 +126,28 @@ struct EffectiveLengthsView: HTML, Sendable {
}
div(.class("card-actions justify-end pt-6 space-y-4 mt-auto")) {
// TODO: Delete.
TrashButton()
.attributes(
.hx.delete(
route: .project(
.detail(
effectiveLength.projectID, .equivalentLength(.delete(id: effectiveLength.id)))
)),
.hx.confirm("Are you sure?"),
.hx.target("#\(id)"),
.hx.swap(.outerHTML)
)
EditButton()
.attributes(.showModal(id: EffectiveLengthForm.id(effectiveLength)))
div(.class("join")) {
TrashButton()
.attributes(
.class("join-item"),
.hx.delete(
route: .project(
.detail(
effectiveLength.projectID,
.equivalentLength(.delete(id: effectiveLength.id))
)
)
),
.hx.confirm("Are you sure?"),
.hx.target("#\(id)"),
.hx.swap(.outerHTML)
)
EditButton()
.attributes(
.class("join-item"),
.showModal(id: EffectiveLengthForm.id(effectiveLength))
)
}
}
EffectiveLengthForm(effectiveLength: effectiveLength)