From e2ad53c7e2524298d92f65c9d5475e25a3e0d5aa Mon Sep 17 00:00:00 2001 From: mathieu J Date: Tue, 27 Feb 2024 13:24:49 +0200 Subject: [PATCH 1/2] :sparkles: (LekaApp): Add RootAccount init and create after signup --- .../AccountCreation/AccountCreationView.swift | 2 ++ .../RootAccount+AccountDocumentProtocol.swift | 0 .../Models/RootAccount/RootAccount+Init.swift | 14 ++++++++++++++ 3 files changed, 16 insertions(+) rename Modules/AccountKit/Sources/Models/{ => RootAccount}/RootAccount+AccountDocumentProtocol.swift (100%) create mode 100644 Modules/AccountKit/Sources/Models/RootAccount/RootAccount+Init.swift diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/AccountCreation/AccountCreationView.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/AccountCreation/AccountCreationView.swift index ccde135835..793b97e1b2 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/AccountCreation/AccountCreationView.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/AccountCreation/AccountCreationView.swift @@ -50,6 +50,7 @@ struct AccountCreationView: View { } .onChange(of: self.authManagerViewModel.userAuthenticationState) { newValue in if newValue == .loggedIn { + self.rootAccountManager.createRootAccount(rootAccount: RootAccount()) self.authManagerViewModel.userIsSigningUp = true self.isVerificationEmailAlertPresented = true } else { @@ -71,6 +72,7 @@ struct AccountCreationView: View { @StateObject private var viewModel = AccountCreationViewViewModel() @ObservedObject private var authManagerViewModel = AuthManagerViewModel.shared private var authManager = AuthManager.shared + private var rootAccountManager = RootAccountManager.shared private var isCreationDisabled: Bool { self.viewModel.email.isInvalidEmail() || self.viewModel.password.isInvalidPassword() diff --git a/Modules/AccountKit/Sources/Models/RootAccount+AccountDocumentProtocol.swift b/Modules/AccountKit/Sources/Models/RootAccount/RootAccount+AccountDocumentProtocol.swift similarity index 100% rename from Modules/AccountKit/Sources/Models/RootAccount+AccountDocumentProtocol.swift rename to Modules/AccountKit/Sources/Models/RootAccount/RootAccount+AccountDocumentProtocol.swift diff --git a/Modules/AccountKit/Sources/Models/RootAccount/RootAccount+Init.swift b/Modules/AccountKit/Sources/Models/RootAccount/RootAccount+Init.swift new file mode 100644 index 0000000000..055569d5b7 --- /dev/null +++ b/Modules/AccountKit/Sources/Models/RootAccount/RootAccount+Init.swift @@ -0,0 +1,14 @@ +// Leka - iOS Monorepo +// Copyright APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +import SwiftUI + +public extension RootAccount { + init(id: String? = "", + rootOwnerUid: String = "") + { + self.id = id + self.rootOwnerUid = rootOwnerUid + } +} From a071a3ef7cc39b9b0c1de11fe43e3282f7bd410b Mon Sep 17 00:00:00 2001 From: mathieu J Date: Tue, 27 Feb 2024 13:55:43 +0200 Subject: [PATCH 2/2] :coffin: (LekaApp): Remove useless signup failed else statement --- .../Views/AccountCreation/AccountCreationView.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/AccountCreation/AccountCreationView.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/AccountCreation/AccountCreationView.swift index 793b97e1b2..95af03a450 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/AccountCreation/AccountCreationView.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/AccountCreation/AccountCreationView.swift @@ -53,8 +53,6 @@ struct AccountCreationView: View { self.rootAccountManager.createRootAccount(rootAccount: RootAccount()) self.authManagerViewModel.userIsSigningUp = true self.isVerificationEmailAlertPresented = true - } else { - // display signup failed alert } } .alert(isPresented: self.$isVerificationEmailAlertPresented) {