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 APIService
|
||||||
|
import DataModels
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import UseCases
|
||||||
|
|
||||||
public struct LoginView: View {
|
public struct LoginView: View {
|
||||||
|
|
||||||
@ -60,13 +62,9 @@ fileprivate extension LoginView {
|
|||||||
|
|
||||||
// MARK: Properties
|
// MARK: Properties
|
||||||
|
|
||||||
private let getUser: GetUserUseCase
|
let authenticated: AuthenticatedClosure
|
||||||
|
|
||||||
// MARK: Initialisers
|
private let getUser: GetUserUseCase = .init()
|
||||||
|
|
||||||
init(authenticated: @escaping AuthenticatedClosure) {
|
|
||||||
self.getUser = .init(authenticated: authenticated)
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: Body
|
// MARK: Body
|
||||||
|
|
||||||
@ -138,9 +136,15 @@ private extension LoginView.LoginContainer {
|
|||||||
guard isAuthenticating else { return }
|
guard isAuthenticating else { return }
|
||||||
|
|
||||||
do {
|
do {
|
||||||
try await getUser(
|
authenticated(
|
||||||
username: username,
|
.init(
|
||||||
password: password
|
username: username,
|
||||||
|
password: password
|
||||||
|
),
|
||||||
|
try await getUser(
|
||||||
|
username: username,
|
||||||
|
password: password
|
||||||
|
)
|
||||||
)
|
)
|
||||||
} catch APIClientError.authenticationFailed {
|
} catch APIClientError.authenticationFailed {
|
||||||
errorMessage = "login.error.authentication_failed.text"
|
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
|
// MARK: - Previews
|
||||||
|
|
||||||
struct LoginView_Previews: PreviewProvider {
|
struct LoginView_Previews: PreviewProvider {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user