From 52e146074fddf47c4a8c4a26786e485b86d5407a Mon Sep 17 00:00:00 2001 From: Thomas Wang <thomaswang@berkeley.edu> Date: Sun, 16 Oct 2022 11:36:39 -0700 Subject: [PATCH 1/2] asd --- .../components/FriendSearch/FriendSearch.js | 53 +++++++++++-------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/frontend/src/components/FriendSearch/FriendSearch.js b/frontend/src/components/FriendSearch/FriendSearch.js index 551878c..f27b9f0 100644 --- a/frontend/src/components/FriendSearch/FriendSearch.js +++ b/frontend/src/components/FriendSearch/FriendSearch.js @@ -17,6 +17,34 @@ function FriendSearch() { const [response, setResponse] = useState(null); const [friends, setFriends] = useState([]); + const getFriends = async () => { + const endpoint = `http://localhost:4000/users/getFriends/?username=${user}` + const res = await fetch(endpoint, { + mode: 'cors', + method: 'GET', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Origin' : 'http://localhost:3000' + } + }) + const data = await res.json(); + console.log(data) + setFriends(data['friends']) + // ).then(response => + // response.json().then(data => data['friends']) + // .then(data => { + // setFriends(data) + // })) + } + + useEffect(() => { + getFriends(); + // console.log(user) + // console.log(typeof friends) + console.log(friends) + }, []) + let inputHandler = (e) => { setInputText(e.target.value); }; @@ -38,27 +66,6 @@ function FriendSearch() { }); }; - const getFriends = async () => { - const endpoint = `http://localhost:4000/users/getFriends/?username=${user}` - fetch(endpoint, { - mode: 'cors', - method: 'GET', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Origin' : 'http://localhost:3000' - } - }).then(response => - response.json().then(data => console.log(data['friends']))) - } - - useEffect(() => { - getFriends(); - console.log(user) - console.log(typeof friends) - console.log(friends) - }, []) - return ( <div className="main"> <h1>Find Friends</h1> @@ -74,14 +81,14 @@ function FriendSearch() { <Button onClick={handleSubmit}>Add Friend</Button> </div> <p class="title"> current friends</p> - {/* <List> + <List> <> { friends.map(friend => <ListItemText primary={friend}/>) } </> - </List> */} + </List> </div> ); } From 41350962362ffb86bf91c99b76b671b177d383da Mon Sep 17 00:00:00 2001 From: Jessica Young <jessica.young@berkeley.edu> Date: Sun, 16 Oct 2022 11:41:18 -0700 Subject: [PATCH 2/2] hide password --- frontend/src/pages/Login/Login.js | 3 +++ frontend/src/pages/SignUp/SignUp.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/frontend/src/pages/Login/Login.js b/frontend/src/pages/Login/Login.js index 9177f12..6ff71bf 100644 --- a/frontend/src/pages/Login/Login.js +++ b/frontend/src/pages/Login/Login.js @@ -29,6 +29,7 @@ function Login() { const [error, setError] = useState(null); const [loading, setLoading] = useState(false); const navigate = useNavigate(); + const [showPassword, setShowPassword] = useState(false); const handleLogin = async () => { @@ -98,6 +99,8 @@ function Login() { style={{ width: "100%" }} variant="outlined" size="small" + type={showPassword ? "text" : + "password"} onChange={handlePasswordChange} /> diff --git a/frontend/src/pages/SignUp/SignUp.js b/frontend/src/pages/SignUp/SignUp.js index 41ce280..0ecfac3 100644 --- a/frontend/src/pages/SignUp/SignUp.js +++ b/frontend/src/pages/SignUp/SignUp.js @@ -34,6 +34,7 @@ function SignUp() { const [error, setError] = useState(null); const [loading, setLoading] = useState(false); const [user, setUser] = useAtom(currUserAtom); + const [showPassword, setShowPassword] = useState(false); const navigate = useNavigate(); @@ -120,6 +121,8 @@ function SignUp() { style={{ width: "100%" }} variant="outlined" size="small" + type={showPassword ? "text" : + "password"} onChange={handlePasswordChange} /> </div>