Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2d3a4e2b

Přidáno uživatelem Michal Schwob před více než 2 roky(ů)

Fixed registering a closing the dialog after success
re #9627

Zobrazit rozdíly:

frontend/src/features/Auth/Register.tsx
1 1
import { Fragment, useEffect } from 'react'
2
import { useSelector } from 'react-redux'
2
import {useDispatch, useSelector} from 'react-redux'
3 3
import { useNavigate } from 'react-router-dom'
4 4
import { RootState } from '../redux/store'
5 5
import LoginDialog from './LoginDialog'
6 6
import NotAuthorized from "../NotAuthorized/NotAuthorized"
7 7
import RegisterDialog from "./RegisterDialog"
8
import {resetIsRegistered} from "./userSlice"
8 9

  
9 10

  
10 11
const Register = () => {
11 12
    const isAdmin = useSelector(
12 13
        (state: RootState) => state.user.roles.includes("ROLE_ADMIN")
13 14
    )
15
    const isRegistered = useSelector(
16
        (state: RootState) => state.user.isRegistered
17
    )
18

  
19
    const dispatch = useDispatch()
20

  
21
    // Redirect to home if the user is logged in
22
    const navigate = useNavigate()
23
    useEffect(() => {
24
        if (isRegistered) {
25
            dispatch(resetIsRegistered())
26
            navigate('/administration')
27
        }
28
    }, [isRegistered, navigate])
14 29

  
15 30
    return (
16 31
        <Fragment>

Také k dispozici: Unified diff