From b73ad65d9a3478f33378d556a80064ab0dbac701 Mon Sep 17 00:00:00 2001 From: nochill Date: Tue, 22 Aug 2023 15:33:27 +0700 Subject: [PATCH] fix navigation --- src/components/Header/index.jsx | 2 ++ src/pages/Login/index.jsx | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/Header/index.jsx b/src/components/Header/index.jsx index 7c22ef0..8af9a48 100644 --- a/src/components/Header/index.jsx +++ b/src/components/Header/index.jsx @@ -1,9 +1,11 @@ import { useDispatch } from 'react-redux'; import { logout } from '../../actions'; +import { useNavigate } from 'react-router-dom'; const Header = (props) => { const dispatch = useDispatch(); + const navigate = useNavigate(); const handleLogoutClick = () => { dispatch(logout()) diff --git a/src/pages/Login/index.jsx b/src/pages/Login/index.jsx index 4a1144a..077b06a 100644 --- a/src/pages/Login/index.jsx +++ b/src/pages/Login/index.jsx @@ -48,7 +48,7 @@ const Login = () => { } useEffect(() => { - if(auth != {}) { + if(Object.keys(auth).length > 0) { navigate("/dashboard") } }) @@ -116,6 +116,15 @@ const Login = () => { +

demo account

+

superadmin

+

email: superadmin@superadmin.com

+

password: 12345

+

admin

+

email: admin@admin.com

+

password: 12345

+

email: author@author

+

password: 12345

)