Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jermxt committed Oct 16, 2022
2 parents 66db3c8 + d814c4c commit 070b22f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion backend/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def addUser():
lat, long = geocode(data['address'])

session = Session()
newUser = User(name=data['name'], username=data['username'], password=data['password'], \
newUser = User(username=data['username'], password=data['password'], \
friends=[], oncall=[], lat=lat, long=long, phone=data["phone"])
session.add(newUser)
try:
Expand Down
40 changes: 34 additions & 6 deletions frontend/src/components/FriendSearch/FriendSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,34 @@ function FriendSearch() {
const [friends, setFriends] = useState([]);
// const [error, setError] = useState(null);

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);
};
Expand All @@ -40,6 +68,7 @@ function FriendSearch() {
});

console.log(response)
getFriends()

// if (response == "true") {
// setUser(inputText)
Expand Down Expand Up @@ -93,18 +122,17 @@ function FriendSearch() {
</Button>
</div>
<p class="title"> current friends</p>
{/* <List>
<List>
<>
{
friends.map(friend =>
<ListItemText primary={friend}/>)
}
</>
</List> */}
</div>

</div>
);
</List>
</div>
</div>
);
}

export default FriendSearch;
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/pages/Login/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {

Expand Down Expand Up @@ -98,6 +99,8 @@ function Login() {
style={{ width: "100%" }}
variant="outlined"
size="small"
type={showPassword ? "text" :
"password"}
onChange={handlePasswordChange}
/>

Expand Down
3 changes: 3 additions & 0 deletions frontend/src/pages/SignUp/SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -120,6 +121,8 @@ function SignUp() {
style={{ width: "100%" }}
variant="outlined"
size="small"
type={showPassword ? "text" :
"password"}
onChange={handlePasswordChange}
/>
</div>
Expand Down

0 comments on commit 070b22f

Please sign in to comment.