diff --git a/app/newHere1/newHere/Registration.swift b/app/newHere1/newHere/Registration.swift index 8ce5812..3a9dae9 100644 --- a/app/newHere1/newHere/Registration.swift +++ b/app/newHere1/newHere/Registration.swift @@ -7,9 +7,13 @@ import SwiftUI +let registerUrlString = "https://here-swe.vercel.app/auth/register" +let apiKey = "qe5YT6jOgiA422_UcdbmVxxG1Z6G48aHV7fSV4TbAPs" + struct RegistrationView: View { @State private var firstName: String = "" @State private var lastName: String = "" + @State private var userName: String = "" @State private var email: String = "" @State private var password: String = "" @State private var confirmPassword: String = "" @@ -23,6 +27,7 @@ struct RegistrationView: View { } Section(header: Text("Credentials")) { + TextField("Username", text: $userName) TextField("Email", text: $email) .keyboardType(.emailAddress) .autocapitalization(.none) @@ -43,6 +48,29 @@ struct RegistrationView: View { func registerUser() { // Implement registration logic print("User registration logic goes here.") + let requestBody: [String: Any] = [ + "firstName": firstName, + "lastName": lastName, + "userName": userName, + "email": email, + "password": password + ] + + let jsonData = try ? JSONSerialization.data(withJSONObject: requestBody) else { + return + } + + let url = URL(string: registerUrlString) else { + print("Invalid URL") + return + } + + var request = URLRequest(url: url) + request.httpMethod = "POST" + request.httpBody = jsonData + request.setValue("application/json", forHTTPHeaderField: "Content-Type") + + URLSession.shared.dataTask(with: request) { data, response, error in }.resume } }