diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 7fa1be84..00000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index 166face2..122b39e3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ *.xcworkspace/xcuserdata/ DerivedData/ build/ +.DS_Store + diff --git a/MobileAcebook.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/MobileAcebook.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..0c67376e --- /dev/null +++ b/MobileAcebook.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,5 @@ + + + + + diff --git a/MobileAcebook/Models/User.swift b/MobileAcebook/Models/User.swift index ea748dd0..1daa5af5 100644 --- a/MobileAcebook/Models/User.swift +++ b/MobileAcebook/Models/User.swift @@ -5,7 +5,11 @@ // Created by Josué Estévez Fernández on 01/10/2023. // -public struct User { - let username: String + + +public struct User: Encodable { + let imgUrl: String + let email: String let password: String + let username: String } diff --git a/MobileAcebook/Services/AuthenticationService.swift b/MobileAcebook/Services/AuthenticationService.swift index 9f7181c3..02b635e9 100644 --- a/MobileAcebook/Services/AuthenticationService.swift +++ b/MobileAcebook/Services/AuthenticationService.swift @@ -4,10 +4,42 @@ // // Created by Josué Estévez Fernández on 01/10/2023. // +import Foundation + + class AuthenticationService: AuthenticationServiceProtocol { + struct Response: Codable { + let message : String + } + func signUp(user: User) -> Bool { - // Logic to call the backend API for signing up - return true // placeholder + guard let url = URL(string: "http://localhost:3000/users") else {return false} + + var urlRequest = URLRequest(url: url) + urlRequest.httpMethod = "POST" + urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") + + let body = user + urlRequest.httpBody = try? JSONEncoder().encode(user) + let task = URLSession.shared.dataTask(with : urlRequest) {data, response, error in + guard let data = data else {return} + do { + let response = try JSONSerialization.jsonObject(with: data, options: .allowFragments) + print(response) + print("User created successfully") + } + catch { + print(error) + } + } + task.resume() + return true } + + + + + } + diff --git a/MobileAcebook/WelcomePageView.swift b/MobileAcebook/WelcomePageView.swift index 96006af9..8d605011 100644 --- a/MobileAcebook/WelcomePageView.swift +++ b/MobileAcebook/WelcomePageView.swift @@ -13,7 +13,7 @@ struct WelcomePageView: View { VStack { Spacer() - Text("Welcome to Acebook!") + Text("Welcome to Pawbook!") .font(.largeTitle) .padding(.bottom, 20) .accessibilityIdentifier("welcomeText")