Integrated the GetUserUseCase use case into the LoginView view for the Login module.
This commit is contained in:
parent
ebee2ddcc0
commit
07ffd2bf80
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user