diff --git a/Modules/Sources/Login/UI/Views/LoginView.swift b/Modules/Sources/Login/UI/Views/LoginView.swift index 6dbb018..16fac56 100644 --- a/Modules/Sources/Login/UI/Views/LoginView.swift +++ b/Modules/Sources/Login/UI/Views/LoginView.swift @@ -7,7 +7,9 @@ // import APIService +import DataModels import SwiftUI +import UseCases public struct LoginView: View { @@ -60,13 +62,9 @@ fileprivate extension LoginView { // MARK: Properties - private let getUser: GetUserUseCase + let authenticated: AuthenticatedClosure - // MARK: Initialisers - - init(authenticated: @escaping AuthenticatedClosure) { - self.getUser = .init(authenticated: authenticated) - } + private let getUser: GetUserUseCase = .init() // MARK: Body @@ -138,9 +136,15 @@ private extension LoginView.LoginContainer { guard isAuthenticating else { return } do { - try await getUser( - username: username, - password: password + authenticated( + .init( + username: username, + password: password + ), + try await getUser( + username: username, + password: password + ) ) } catch APIClientError.authenticationFailed { errorMessage = "login.error.authentication_failed.text" @@ -153,6 +157,10 @@ private extension LoginView.LoginContainer { } +// MARK: - Type aliases + +public typealias AuthenticatedClosure = (Account, User) -> Void + // MARK: - Previews struct LoginView_Previews: PreviewProvider {