Projekt

Obecné

Profil

Stáhnout (651 Bajtů) Statistiky
| Větev: | Tag: | Revize:
1
import { Fragment, useEffect } from 'react'
2
import { useSelector } from 'react-redux'
3
import { useNavigate } from 'react-router-dom'
4
import { RootState } from '../redux/store'
5
import LoginDialog from './LoginDialog'
6

    
7

    
8
const Login = () => {
9
    const userLoggedIn = useSelector(
10
        (state: RootState) => state.user.isLoggedIn
11
    )
12

    
13
    // Redirect to home if the user is logged in
14
    const navigate = useNavigate()
15
    useEffect(() => {
16
        if (userLoggedIn) {
17
            navigate('/')
18
        }
19
    }, [userLoggedIn, navigate])
20

    
21
    return (
22
        <Fragment>
23
            <LoginDialog />
24
        </Fragment>
25
    )
26
}
27

    
28
export default Login
(1-1/7)