|
|
|
@ -21,7 +21,13 @@ struct UserCreationFormView: View { |
|
|
|
@State var lastName: String = "" |
|
|
|
@State var lastName: String = "" |
|
|
|
@State var phone: String = "" |
|
|
|
@State var phone: String = "" |
|
|
|
|
|
|
|
|
|
|
|
@State var showUnmatchingPasswordView = false |
|
|
|
@State var showAlertView = false |
|
|
|
|
|
|
|
@State var alertMessage: String = "" { |
|
|
|
|
|
|
|
didSet { |
|
|
|
|
|
|
|
self.showAlertView = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@State var selectedCountryIndex = 0 |
|
|
|
@State var selectedCountryIndex = 0 |
|
|
|
|
|
|
|
|
|
|
|
@State var dataCollectAuthorized: Bool = false |
|
|
|
@State var dataCollectAuthorized: Bool = false |
|
|
|
@ -41,7 +47,6 @@ struct UserCreationFormView: View { |
|
|
|
TextField("Email", text: self.$email) |
|
|
|
TextField("Email", text: self.$email) |
|
|
|
.keyboardType(.emailAddress) |
|
|
|
.keyboardType(.emailAddress) |
|
|
|
.textInputAutocapitalization(.never) |
|
|
|
.textInputAutocapitalization(.never) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
Section { |
|
|
|
@ -87,7 +92,7 @@ struct UserCreationFormView: View { |
|
|
|
.onAppear { |
|
|
|
.onAppear { |
|
|
|
self._selectCountry() |
|
|
|
self._selectCountry() |
|
|
|
} |
|
|
|
} |
|
|
|
.alert("Les mots de passe ne correspondent pas", isPresented: self.$showUnmatchingPasswordView, actions: { |
|
|
|
.alert(self.alertMessage, isPresented: self.$showAlertView, actions: { |
|
|
|
Button("Ok", action: {}) |
|
|
|
Button("Ok", action: {}) |
|
|
|
} ) |
|
|
|
} ) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -104,7 +109,27 @@ struct UserCreationFormView: View { |
|
|
|
fileprivate func _create() { |
|
|
|
fileprivate func _create() { |
|
|
|
|
|
|
|
|
|
|
|
guard self.password1 == self.password2 else { |
|
|
|
guard self.password1 == self.password2 else { |
|
|
|
self.showUnmatchingPasswordView = true |
|
|
|
self.alertMessage = "Les mots de passe ne correspondent pas" |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
guard username.count > 2 else { |
|
|
|
|
|
|
|
self.alertMessage = "Veuillez renseigner au moins 3 caractères pour votre nom d'utilisateur" |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
guard self.email.isValidEmail() else { |
|
|
|
|
|
|
|
self.alertMessage = "L'adresse email n'est pas valide" |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
guard firstName.count > 0 else { |
|
|
|
|
|
|
|
self.alertMessage = "Votre prénom ne peut pas être vide" |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
guard lastName.count > 0 else { |
|
|
|
|
|
|
|
self.alertMessage = "Votre nom ne peut pas être vide" |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|