forked from rachelwuuu/Buddify_uoftHacks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HomePage.js
82 lines (73 loc) · 3.34 KB
/
HomePage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import React, { useState, useEffect } from 'react';
import { getAccount } from '../auth'
import { LoginDialog } from '../auth/LoginDialog'
import { Avatar } from "@material-ui/core";
import "./homePage.css";
import axios from 'axios';
export default function HomePage() {
const [email,setEmail] = useState(null);
const [name,setName] = useState(null);
const [headline,setHeadline] = useState(null);
const [countryRegion,setCountryRegion] = useState(null);
const [homeCountryRegion,setHomeCountryRegion] = useState(null);
const [locationCity,setLocationCity] = useState(null);
const [contactInfo,setContactInfo] = useState(null);
const [about,setAbout] = useState(null);
const [avatar,setAvatar] = useState(null);
const [friends,setFriends] = useState(null);
function loop(friends){
if(friends){
return friends.map((friend)=>(
<div key={friend} className="friend">
<Avatar src={friend.avatar} className="friendAvatar"></Avatar>
<p>{friend.name}</p>
<p>Email: {friend.email}</p>
<p>Headline: {friend.intro.headline}</p>
<p>Country Region: {friend.intro.countryRegion}</p>
<p>Home Country: {friend.intro.homeCountryRegion}</p>
<p>Location City: {friend.intro.locationCity}</p>
</div>
));
}
}
function loopName(friends){
if(friends){
return friends.map((friend)=>(<p key={friend.name}>{friend.name}</p>));
}
}
useEffect(async ()=>{
const response=await axios(
'http://localhost:3000/data',
);
setEmail(response.data.gmailTest.email)
setName(response.data.gmailTest.name)
setHeadline(response.data.gmailTest.intro.headline)
setCountryRegion(response.data.gmailTest.intro.countryRegion)
setHomeCountryRegion(response.data.gmailTest.intro.homeCountryRegion)
setLocationCity(response.data.gmailTest.intro.locationCity)
setContactInfo(response.data.gmailTest.intro.contactInfo)
setAbout(response.data.gmailTest.intro.about)
setAvatar(response.data.gmailTest.avatar)
setFriends(response.data.gmailTest.friends)
})
return (
<div className="homePage">
<div className="welcomeInfo">Welcome, {getAccount().name} <Avatar alt={getAccount().name} src={getAccount().photoURL} id="mainPic" />
<div className="friends">
<div className="personalInfo">
<Avatar src={avatar} className="friendAvatar"></Avatar>
<p>Name: {name}</p>
<p>Email: {email}</p>
<p>Headline: {headline}</p>
<p>Country Region: {countryRegion}</p>
<p>Home Country: {homeCountryRegion}</p>
<p>Location City:{locationCity}</p>
<p>Contact Info:{contactInfo}</p>
<p>About: {about}</p>
</div>
{loop(friends)}
</div>
</div>
</div>
)
}