From 000f8ce16b8db1af6b0103c4155a03c35cb5ef98 Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Fri, 24 Jan 2025 17:07:59 -0500 Subject: [PATCH] feat: Working on fixing todos. --- .../App/Extensions/RouteBuilder+protected.swift | 2 -- .../ViewControllerLive/Views/Users/UserForm.swift | 14 ++++---------- .../ViewControllerLive/Views/Utils/Buttons.swift | 9 --------- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/Sources/App/Extensions/RouteBuilder+protected.swift b/Sources/App/Extensions/RouteBuilder+protected.swift index ed8acfa..dc08bec 100644 --- a/Sources/App/Extensions/RouteBuilder+protected.swift +++ b/Sources/App/Extensions/RouteBuilder+protected.swift @@ -2,8 +2,6 @@ import DatabaseClientLive import SharedModels import Vapor -// TODO: Fix before production. - extension RoutesBuilder { // Used to ensure views are protected, redirects users to the login page if they're diff --git a/Sources/ViewControllerLive/Views/Users/UserForm.swift b/Sources/ViewControllerLive/Views/Users/UserForm.swift index c514299..73d0c77 100644 --- a/Sources/ViewControllerLive/Views/Users/UserForm.swift +++ b/Sources/ViewControllerLive/Views/Users/UserForm.swift @@ -20,7 +20,7 @@ struct UserForm: HTML, Sendable { form( .id(.user(.form)), .class("user-form"), - .hx.post(context.targetURL), + .hx.post(route: context.targetURL), .hx.pushURL(context.pushURL), .hx.target(context.target), .hx.swap(context == .create ? .afterBegin.transition(true).swap("0.5s") : .outerHTML), @@ -101,18 +101,12 @@ struct UserForm: HTML, Sendable { } } - // TODO: Return a ViewRoute. - var targetURL: String { + var targetURL: ViewRoute { switch self { case .create: - return "/users" + return .user(.index) case .login: - return "/login" - // let path = "/login" - // if let next { - // return "\(path)?next=\(next)" - // } - // return path + return .login(.index()) } } } diff --git a/Sources/ViewControllerLive/Views/Utils/Buttons.swift b/Sources/ViewControllerLive/Views/Utils/Buttons.swift index c63fe82..9341d7f 100644 --- a/Sources/ViewControllerLive/Views/Utils/Buttons.swift +++ b/Sources/ViewControllerLive/Views/Utils/Buttons.swift @@ -2,15 +2,6 @@ import Elementary import SharedModels import URLRouting -// TODO: Remove. -struct ToggleFormButton: HTML, Sendable { - var content: some HTML { - a(.href("javascript:void(0)"), .on(.click, "toggleContent('form')"), .class("btn-add")) { - "+" - } - } -} - enum Button { @Sendable