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