Projekt

Obecné

Profil

Stáhnout (786 Bajtů) Statistiky
| Větev: | Tag: | Revize:
1
import { Button } from '@mui/material'
2
import { Fragment } from 'react'
3
import { useDispatch, useSelector } from 'react-redux'
4
import { logout } from '../Auth/userSlice'
5
import { RootState } from '../redux/store'
6

    
7
const Home = () => {
8
    const dispatch = useDispatch()
9

    
10
    const userLoggedIn = useSelector(
11
        (state: RootState) => state.user.isLoggedIn
12
    )
13

    
14
    return (
15
        <Fragment>
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
        </Fragment>
28
    )
29
}
30

    
31
export default Home
    (1-1/1)