1
|
import { Button } from '@mui/material'
|
2
|
import { useDispatch, useSelector } from 'react-redux'
|
3
|
import { logout } from '../Auth/userSlice'
|
4
|
import { RootState } from '../redux/store'
|
5
|
|
6
|
const Home = () => {
|
7
|
const dispatch = useDispatch()
|
8
|
|
9
|
const userLoggedIn = useSelector(
|
10
|
(state: RootState) => state.user.isLoggedIn
|
11
|
)
|
12
|
|
13
|
return (
|
14
|
<>
|
15
|
<h1>Home</h1>
|
16
|
{userLoggedIn ? (
|
17
|
<Button
|
18
|
size="large"
|
19
|
variant="contained"
|
20
|
color="primary"
|
21
|
onClick={() => dispatch(logout())}
|
22
|
>
|
23
|
Logout
|
24
|
</Button>
|
25
|
) : null}
|
26
|
</>
|
27
|
)
|
28
|
}
|
29
|
|
30
|
export default Home
|