feat: Adds logout route and switches user navbar item to dropdown menu.

This commit is contained in:
2026-02-09 12:32:30 -05:00
parent 5a7cf4714b
commit 88af6f722e
5 changed files with 39 additions and 7 deletions

View File

@@ -647,7 +647,17 @@ extension SiteRoute.View.ProjectRoute.DuctSizingRoute {
extension SiteRoute.View.UserRoute {
func renderView(on request: ViewController.Request) async -> AnySendableHTML {
@Dependency(\.auth) var auth
switch self {
case .logout:
return await request.view {
await ResultView {
try auth.logout()
} onSuccess: {
LoginForm(next: nil)
}
}
case .profile(let route):
return await route.renderView(on: request)
}

View File

@@ -14,7 +14,8 @@ struct HomeView: HTML, Sendable {
.class("btn btn-ghost btn-secondary text-lg"),
.hx.get(route: .login(.index())),
.hx.target("body"),
.hx.swap(.outerHTML)
.hx.swap(.outerHTML),
.hx.pushURL(true)
) {
"Login"
}

View File

@@ -49,14 +49,21 @@ struct Navbar: HTML, Sendable {
}
if userProfile {
// TODO: Make dropdown
div(.class("flex-none")) {
a(
.href(route: .user(.profile(.index))),
) {
div(.class("flex-none dropdown dropdown-end dropdown-hover")) {
div(.class("btn m-1"), .tabindex(0), .role("button")) {
SVG(.circleUser)
}
.navButton()
.tooltip("Profile")
ul(
.tabindex(-1),
.class("dropdown-content menu bg-base-200 rounded-box z-1 w-52 py-2 shadow-sm")
) {
li {
a(.href(route: .user(.profile(.index)))) { "Profile" }
}
li {
a(.href(route: .user(.logout))) { "Logout" }
}
}
}
}
}