feat: Adds reset password views and view routes.
This commit is contained in:
@@ -49,7 +49,10 @@ struct UserDetail: HTML, Sendable {
|
||||
)
|
||||
// TODO: trigger the reset password route.
|
||||
button(
|
||||
.class("btn-primary")
|
||||
.class("btn-primary"),
|
||||
.hx.target(.id(.float)),
|
||||
.hx.get(route: .resetPassword(.index(id: user.id))),
|
||||
.hx.trigger(.event(.click))
|
||||
) { "Reset Password" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ struct UserForm: HTML, Sendable {
|
||||
let context: Context
|
||||
|
||||
var content: some HTML {
|
||||
if context == .create {
|
||||
if context.isFloat {
|
||||
Float(shouldDisplay: true) {
|
||||
makeForm()
|
||||
}
|
||||
@@ -26,7 +26,7 @@ struct UserForm: HTML, Sendable {
|
||||
.hx.swap(context == .create ? .afterBegin.transition(true).swap("0.5s") : .outerHTML),
|
||||
.hx.on(
|
||||
.afterRequest,
|
||||
.ifSuccessful(.resetForm, .toggleContent(.float))
|
||||
context.toggleContent ? .ifSuccessful(.resetForm, .toggleContent(.float)) : .ifSuccessful(.resetForm)
|
||||
)
|
||||
) {
|
||||
if case let .login(next) = context, let next {
|
||||
@@ -70,6 +70,21 @@ struct UserForm: HTML, Sendable {
|
||||
return true
|
||||
}
|
||||
|
||||
var isFloat: Bool {
|
||||
switch self {
|
||||
case .create,
|
||||
.resetPassword:
|
||||
return true
|
||||
case .login:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
var toggleContent: Bool {
|
||||
guard case .resetPassword = self else { return true }
|
||||
return false
|
||||
}
|
||||
|
||||
var showUsername: Bool {
|
||||
switch self {
|
||||
case .create: return true
|
||||
@@ -120,8 +135,7 @@ struct UserForm: HTML, Sendable {
|
||||
case .login:
|
||||
return .body
|
||||
case .resetPassword:
|
||||
// FIX: doesn't return anything
|
||||
return .this
|
||||
return .id(.float)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,9 +145,8 @@ struct UserForm: HTML, Sendable {
|
||||
return .user(.index)
|
||||
case .login:
|
||||
return .login(.index())
|
||||
case .resetPassword:
|
||||
// FIX: Route.
|
||||
return .user(.index)
|
||||
case let .resetPassword(id: id):
|
||||
return .resetPassword(.index(id: id))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user