-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
246 additions
and
9 deletions.
There are no files selected for viewing
Binary file added
BIN
+28.8 KB
...codeproj/project.xcworkspace/xcuserdata/sophia.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// | ||
// Registration.swift | ||
// newHere | ||
// | ||
// Created by TRACY LI on 2023/11/4. | ||
// | ||
|
||
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 = "" | ||
@Binding var isRegistered: Bool | ||
|
||
var body: some View { | ||
NavigationView { | ||
Form { | ||
Section(header: Text("Name")) { | ||
TextField("First Name", text: $firstName) | ||
TextField("Last Name", text: $lastName) | ||
} | ||
|
||
Section(header: Text("Credentials")) { | ||
TextField("Username", text: $userName) | ||
TextField("Email", text: $email) | ||
.keyboardType(.emailAddress) | ||
.autocapitalization(.none) | ||
SecureField("Password", text: $password) | ||
SecureField("Confirm Password", text: $confirmPassword) | ||
} | ||
|
||
Section { | ||
Button(action: registerUser) { | ||
Text("Submit") | ||
} | ||
} | ||
} | ||
.navigationBarTitle("Registration") | ||
} | ||
} | ||
|
||
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 | ||
] | ||
|
||
guard let jsonData = try? JSONSerialization.data(withJSONObject: requestBody) | ||
else { | ||
return | ||
} | ||
|
||
guard let url = URL(string: registerUrlString) else { | ||
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() | ||
self.isRegistered = true | ||
} | ||
} | ||
|
||
struct RegistrationView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
RegistrationView(isRegistered: self.isRegistered) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
Note that base url will change with deployment of backend. | ||
|
||
# AUTH | ||
- REGISTER: POST "http://localhost:6000/auth/register" | ||
- params: | ||
{ | ||
"userName": "JohnDED", | ||
"firstName": "John", | ||
"lastName": "Doe", | ||
"email": "[email protected]", | ||
"password": "secretpassword" | ||
} | ||
|
||
- LOGIN: GET "http://localhost:6000/auth/login" | ||
- params: | ||
{ | ||
"inputLogin": "JaneD", | ||
"password": "secretpassword" | ||
} | ||
|
||
# MESSAGE | ||
- POST MESSAGE: POST "http://localhost:6000/message/post_message" | ||
- params: | ||
{ | ||
"user_id": "653d51478ff5b3c9ace45c26", | ||
"text": "Hi, this is a test message - Jane", | ||
"visibility": "friends", | ||
"location": { | ||
"type": "Point", | ||
"coordinates": [40.7128, -74.0060] | ||
} | ||
} | ||
|
||
- DELETE MESSAGE: POST "http://localhost:6000/message/delete_message" | ||
- params: | ||
{ | ||
"messageId": "653d62a37ce9c61f28dcaa7f" | ||
} | ||
|
||
- INCREMENT LIKES: POST "http://localhost:6000/message/increment_likes" | ||
- params: | ||
{ | ||
"id": "653d62de7ce9c61f28dcaa87" | ||
} | ||
|
||
- CHANGE VISIBILITY: POST "http://localhost:6000/message/change_visibility" | ||
- params: | ||
{ | ||
"id": "dsfsf", | ||
"new_data": "" | ||
} | ||
|
||
# REPLY | ||
- ADD REPLY: POST "http://localhost:6000/reply/reply_to_message" | ||
- params: | ||
{ | ||
"message_id": "653ea4a35b858b2542ea4f13", | ||
"content": "this is a test reply to a test message" | ||
} | ||
|
||
- LIKE REPLY: GET "http://localhost:6000/reply/like_reply" | ||
- params: | ||
{ | ||
"reply_id": "somekindofreplyid" | ||
} | ||
|
||
# USER | ||
- SEARCH USER BY USER_ID: GET "http://localhost:6000/user/search" | ||
- params: | ||
{ | ||
"userId": "" | ||
} | ||
- SEARCH USER BY EMAIL: GET "http://localhost:6000/user/search" | ||
- params: | ||
{ | ||
"email": "[email protected]" | ||
} | ||
|
||
- SEARCH USER BY USERNAME: GET "http://localhost:6000/user/search" | ||
- params: | ||
{ | ||
"userName": "" | ||
} | ||
|
||
- ADD USER FRIEND: PUT "http://localhost:6000/user/userid" | ||
- params: | ||
{ | ||
"friendId": "friend's id" | ||
} | ||
|
||
- GET FRIEND OF USER: GET "http://localhost:6000/user/userId/friends" | ||
|
||
- TOGGLE NOTIFY FRIENDS: PUT "http://localhost:6000/user/userId/toggle-notify-friends" | ||
|
||
- UPDATE PROFILE: PUT "http://localhost:6000/user/userId/update-profile" | ||
- params: | ||
{ | ||
"userName": "john_d", | ||
"password": "hello", | ||
"firstName": "Johnn", | ||
"lastName": "Doee", | ||
"email": "[email protected]", | ||
"avatar": "" | ||
} | ||
|
||
- REMOVE USER FRIEND: GET "http://localhost:6000/user/search/[email protected]" | ||
|
||
- DELETE USER: DELETE "http://localhost:6000/user/653d58a37ab5eaf376965b82" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"version": 2, | ||
"builds": [ | ||
{ | ||
"src": "server.js", | ||
"use": "@vercel/node" | ||
} | ||
], | ||
"routes": [ | ||
{ | ||
"src": "/auth/(.*)", | ||
"dest": "/server.js" | ||
}, | ||
{ | ||
"src": "/message/(.*)", | ||
"dest": "/server.js" | ||
}, | ||
{ | ||
"src": "/reply/(.*)", | ||
"dest": "/server.js" | ||
}, | ||
{ | ||
"src": "/user/(.*)", | ||
"dest": "/server.js" | ||
} | ||
] | ||
} | ||
|