feat: Updating id key for usage in views, for typesafe keys
This commit is contained in:
@@ -9,13 +9,13 @@ struct UserDetail: HTML, Sendable {
|
||||
let user: User?
|
||||
|
||||
var content: some HTML {
|
||||
Float(shouldDisplay: user != nil, resetURL: "/users") {
|
||||
Float(shouldDisplay: user != nil, resetURL: .user(.index)) {
|
||||
if let user {
|
||||
form(
|
||||
.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';")
|
||||
.hx.target(.id(.user(.row(id: user.id)))),
|
||||
.hx.on(.afterRequest, .toggleContent(.float))
|
||||
) {
|
||||
div(.class("row")) {
|
||||
makeLabel(for: "username", value: "Username:")
|
||||
@@ -39,9 +39,12 @@ struct UserDetail: HTML, Sendable {
|
||||
.hx.delete(route: .user(.get(id: user.id))),
|
||||
.hx.trigger(.event(.click)),
|
||||
.hx.swap(.outerHTML),
|
||||
.hx.target(.user(.row(id: user.id))),
|
||||
.hx.target(.id(.user(.row(id: user.id)))),
|
||||
.hx.confirm("Are you sure you want to delete this user?"),
|
||||
.custom(name: "hx-on::after-request", value: "toggleContent('float'); window.location.href='/users';")
|
||||
.hx.on(
|
||||
.afterRequest,
|
||||
.toggleContent(.float), .setWindowLocation(to: .user(.index))
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user