|
|
|
|
@ -10,7 +10,8 @@ import LeStorage |
|
|
|
|
|
|
|
|
|
struct UserCreationFormView: View { |
|
|
|
|
|
|
|
|
|
@Binding var showLoginScreen: Bool |
|
|
|
|
@Binding var isPresented: Bool |
|
|
|
|
@Binding var showEmailValidationMessage: Bool |
|
|
|
|
|
|
|
|
|
@State var username: String = "" |
|
|
|
|
@State var password1: String = "" |
|
|
|
|
@ -39,6 +40,7 @@ struct UserCreationFormView: View { |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
|
|
|
|
|
NavigationStack { |
|
|
|
|
Form { |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
@ -89,6 +91,7 @@ struct UserCreationFormView: View { |
|
|
|
|
}).disabled(!self.dataCollectAuthorized) |
|
|
|
|
.frame(maxWidth: .infinity) |
|
|
|
|
} |
|
|
|
|
}.navigationTitle("Créez votre compte") |
|
|
|
|
} |
|
|
|
|
.onAppear { |
|
|
|
|
self._selectCountry() |
|
|
|
|
@ -152,12 +155,12 @@ struct UserCreationFormView: View { |
|
|
|
|
country: self.countries[self.selectedCountryIndex]) |
|
|
|
|
|
|
|
|
|
let service = try Store.main.service() |
|
|
|
|
let user: User = try await service.createAccount(user: userCreationForm) |
|
|
|
|
let _: User = try await service.createAccount(user: userCreationForm) |
|
|
|
|
|
|
|
|
|
DispatchQueue.main.async { |
|
|
|
|
DataStore.shared.user = user |
|
|
|
|
self.isLoading = false |
|
|
|
|
self.showLoginScreen = true |
|
|
|
|
self.showEmailValidationMessage = true |
|
|
|
|
self.isPresented = false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} catch { |
|
|
|
|
@ -169,24 +172,6 @@ struct UserCreationFormView: View { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
struct UserCreationView: View { |
|
|
|
|
|
|
|
|
|
@State var showLoginScreen: Bool = false |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
|
|
|
|
|
Group { |
|
|
|
|
if self.showLoginScreen { |
|
|
|
|
LoginView(showEmailValidationMessage: true) { _ in } |
|
|
|
|
} else { |
|
|
|
|
UserCreationFormView(showLoginScreen: self.$showLoginScreen) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.navigationTitle("Créez votre compte") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#Preview { |
|
|
|
|
UserCreationView() |
|
|
|
|
UserCreationFormView(isPresented: .constant(true), showEmailValidationMessage: .constant(true)) |
|
|
|
|
} |
|
|
|
|
|