fix navigation

This commit is contained in:
nochill 2023-08-22 15:33:27 +07:00
parent f848013787
commit b73ad65d9a
2 changed files with 12 additions and 1 deletions

View File

@ -1,9 +1,11 @@
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import { logout } from '../../actions'; import { logout } from '../../actions';
import { useNavigate } from 'react-router-dom';
const Header = (props) => { const Header = (props) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const navigate = useNavigate();
const handleLogoutClick = () => { const handleLogoutClick = () => {
dispatch(logout()) dispatch(logout())

View File

@ -48,7 +48,7 @@ const Login = () => {
} }
useEffect(() => { useEffect(() => {
if(auth != {}) { if(Object.keys(auth).length > 0) {
navigate("/dashboard") navigate("/dashboard")
} }
}) })
@ -116,6 +116,15 @@ const Login = () => {
</div> </div>
</form> </form>
</div> </div>
<p>demo account</p>
<p>superadmin</p>
<p>email: superadmin@superadmin.com</p>
<p>password: 12345</p>
<p>admin</p>
<p>email: admin@admin.com</p>
<p>password: 12345</p>
<p>email: author@author </p>
<p>password: 12345</p>
</div> </div>
</> </>
) )