feat: Cleans up routes.

This commit is contained in:
2025-01-19 13:33:01 -05:00
parent 1c8748211c
commit b23dc6bf07
32 changed files with 958 additions and 1786 deletions

View File

@@ -12,7 +12,7 @@ struct UserDetail: HTML, Sendable {
Float(shouldDisplay: user != nil, resetURL: "/users") {
if let user {
form(
.hx.post(route: .user(.shared(.get(id: user.id)))),
.hx.post(route: .user(.get(id: user.id))),
.hx.swap(.outerHTML),
.hx.target(.user(.row(id: user.id))),
.custom(name: "hx-on::after-request", value: "toggleContent('float'); window.location.href='/users';")
@@ -36,7 +36,7 @@ struct UserDetail: HTML, Sendable {
) { "Update" }
Button.danger { "Delete" }
.attributes(
.hx.delete(route: .user(.shared(.get(id: user.id)))),
.hx.delete(route: .user(.get(id: user.id))),
.hx.trigger(.event(.click)),
.hx.swap(.outerHTML),
.hx.target(.user(.row(id: user.id))),

View File

@@ -1,5 +1,6 @@
import Elementary
import ElementaryHTMX
import SharedModels
// Form used to login or create a new user.
struct UserForm: HTML, Sendable {
@@ -28,6 +29,9 @@ struct UserForm: HTML, Sendable {
value: "if(event.detail.successful) this.reset(); toggleContent('float');"
)
) {
if case let .login(next) = context, let next {
input(.type(.hidden), .name("next"), .value(next))
}
div(.class("row")) {
input(.type(.text), .id("username"), .name("username"), .placeholder("Username"), .autofocus, .required)
}
@@ -104,12 +108,13 @@ struct UserForm: HTML, Sendable {
switch self {
case .create:
return "/users"
case let .login(next: next):
let path = "/login"
if let next {
return "\(path)?next=\(next)"
}
return path
case .login:
return "/login"
// let path = "/login"
// if let next {
// return "\(path)?next=\(next)"
// }
// return path
}
}
}

View File

@@ -45,7 +45,7 @@ struct UserTable: HTML {
td { user.email }
td {
Button.detail().attributes(
.hx.get(route: .user(.shared(.get(id: user.id)))),
.hx.get(route: .user(.get(id: user.id))),
.hx.target(.float),
.hx.swap(.outerHTML),
.hx.pushURL(true)