feat: Adds reset password views and view routes.

This commit is contained in:
2025-01-27 09:01:23 -05:00
parent 8a79ab0b02
commit f3ffdbf41b
10 changed files with 155 additions and 9 deletions

View File

@@ -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))
}
}
}