parent
337ebc07a3
commit
595205a9e1
@ -0,0 +1,58 @@ |
|||||||
|
// |
||||||
|
// UserCreationView.swift |
||||||
|
// PadelClub |
||||||
|
// |
||||||
|
// Created by Laurent Morvillier on 13/02/2024. |
||||||
|
// |
||||||
|
|
||||||
|
import SwiftUI |
||||||
|
import LeStorage |
||||||
|
|
||||||
|
struct UserCreationView: View { |
||||||
|
|
||||||
|
@State var username: String = "" |
||||||
|
@State var password: String = "" |
||||||
|
@State var email: String = "" |
||||||
|
|
||||||
|
var body: some View { |
||||||
|
|
||||||
|
Form { |
||||||
|
|
||||||
|
TextField("Username", text: self.$username) |
||||||
|
TextField("Password", text: self.$password) |
||||||
|
TextField("Email", text: self.$email) |
||||||
|
|
||||||
|
Section { |
||||||
|
Button(action: { |
||||||
|
self._create() |
||||||
|
}, label: { |
||||||
|
Text("Create") |
||||||
|
}) |
||||||
|
.frame(maxWidth: .infinity) |
||||||
|
} |
||||||
|
} |
||||||
|
.navigationTitle("Create user") |
||||||
|
} |
||||||
|
|
||||||
|
fileprivate func _create() { |
||||||
|
guard let service = Store.main.service else { |
||||||
|
return |
||||||
|
} |
||||||
|
Task { |
||||||
|
do { |
||||||
|
try await service.createAccount( |
||||||
|
username: self.username, |
||||||
|
password: self.password, |
||||||
|
email: self.email) |
||||||
|
} catch { |
||||||
|
Logger.error(error) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
#Preview { |
||||||
|
UserCreationView() |
||||||
|
} |
||||||
Loading…
Reference in new issue