Projekt

Obecné

Profil

Stáhnout (651 Bajtů) Statistiky
| Větev: | Tag: | Revize:
1 8370b6c1 Vaclav Honzik
import { Fragment, useEffect } from 'react'
2 6129910f Vaclav Honzik
import { useSelector } from 'react-redux'
3 8370b6c1 Vaclav Honzik
import { useNavigate } from 'react-router-dom'
4
import { RootState } from '../redux/store'
5 6129910f Vaclav Honzik
import LoginDialog from './LoginDialog'
6 8370b6c1 Vaclav Honzik
7 c7d2ced1 Václav Honzík
8
const Login = () => {
9 8370b6c1 Vaclav Honzik
    const userLoggedIn = useSelector(
10
        (state: RootState) => state.user.isLoggedIn
11
    )
12 6129910f Vaclav Honzik
13
    // Redirect to home if the user is logged in
14 8370b6c1 Vaclav Honzik
    const navigate = useNavigate()
15
    useEffect(() => {
16
        if (userLoggedIn) {
17
            navigate('/')
18
        }
19
    }, [userLoggedIn, navigate])
20 c7d2ced1 Václav Honzík
21
    return (
22 8370b6c1 Vaclav Honzik
        <Fragment>
23 6129910f Vaclav Honzik
            <LoginDialog />
24 8370b6c1 Vaclav Honzik
        </Fragment>
25 c7d2ced1 Václav Honzík
    )
26
}
27
28 8370b6c1 Vaclav Honzik
export default Login