-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHome.jsx
More file actions
61 lines (56 loc) · 1.76 KB
/
Home.jsx
File metadata and controls
61 lines (56 loc) · 1.76 KB
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
import React, { useEffect } from 'react'
import { Link, useHistory } from "react-router-dom"
import { useAuth } from '../context/AuthContext'
//components
import Button from '@material-ui/core/Button';
export default function Home() {
const { currentUser, logout } = useAuth()
const history = useHistory()
useEffect(() => {
console.log('currentUser: ', currentUser);
if (!currentUser) {
history.push("/signin")
} else {
history.push("/")
}
}, [currentUser])
// handle functions
function handleLogout(e) {
logout()
}
function handleUpdateProfile() {
history.push('/update-profile')
}
function handleSendEmailLink() {
history.push({
pathname: '/send-email-link',
state: {
btnName: "Send Email Link"
}
})
}
return (
<div>
{
currentUser ?
(
<div>
<h1>My home</h1>
<Button variant="contained" color="primary" onClick={handleLogout}>
Logout
</Button>
<br />
<Button variant="contained" color="secondary" onClick={handleUpdateProfile}>
Update profile
</Button>
<br />
<Button variant="contained" color="secondary" onClick={handleSendEmailLink}>
Send Email Link
</Button>
</div>
) :
<h1>Loading...</h1>
}
</div>
)
}