diff --git a/src/assets/style/navbarStyles.css b/src/assets/style/navbarStyles.css index 6c25bfc..813f49a 100644 --- a/src/assets/style/navbarStyles.css +++ b/src/assets/style/navbarStyles.css @@ -11,18 +11,18 @@ z-index: 9999; border-bottom: 3px solid #0C489E; } -#navbar{ +#navbar div{ display: flex; align-items: center; justify-content: center; } -#navbar li{ +#navbar div li{ list-style: none; padding: 0 20px; position: relative; } -#navbar li a{ +#navbar div li a{ text-decoration: none; font-size: 1.5rem; font-weight: 600; @@ -30,11 +30,11 @@ color: black; transition: 0.3s ease-in-out; } -#navbar li a:hover{ +#navbar div li a:hover{ color: #0C489E; } -#navbar li a:hover::after, -#navbar li a:focus::after{ +#navbar div li a:hover::after, +#navbar div li a:focus::after{ content: ""; width: 60%; height: 2px; @@ -62,14 +62,27 @@ text-align: center; } #sidebar{ + font-size: 1.3rem; + font-weight: 600; + font-family: 微軟正黑體; +} +#sidebartop{ + align-items: center; + justify-content: center; + padding: 0; + display: flex; +} +#sidebarbottom{ align-items: center; justify-content: center; padding: 0; + display: flex; } #sidebar li{ list-style: none; padding: 0 20px; position: relative; + text-align: left; } #sidebar li a{ text-decoration: none; diff --git a/src/auth/utils.js b/src/auth/utils.js index 9ed37f9..94e8de5 100644 --- a/src/auth/utils.js +++ b/src/auth/utils.js @@ -1,4 +1,4 @@ -import useJwt from 'auth/jwt/coreUseJwt' +import useJwt from 'auth/jwt/coreUseJwt'; /** * Return if user is logged in @@ -6,16 +6,16 @@ import useJwt from 'auth/jwt/coreUseJwt' * e.g. If you are using cookies to store the application please update this function */ // eslint-disable-next-line arrow-body-style -export const hostname = "localhost" -const hostPort = "8080" -export const hostPath = `http://${hostname}:${hostPort}` -export const apiPath = `${hostPath}/api` +export const hostname = 'localhost'; +const hostPort = '8090'; +export const hostPath = `http://${hostname}:${hostPort}`; +export const apiPath = `${hostPath}/api`; export const isUserLoggedIn = () => { - return localStorage.getItem('userData') && localStorage.getItem(useJwt.jwtConfig.storageTokenKeyName) -} + return localStorage.getItem('userData') && localStorage.getItem(useJwt.jwtConfig.storageTokenKeyName); +}; -export const getUserData = () => JSON.parse(localStorage.getItem('userData')) +export const getUserData = () => JSON.parse(localStorage.getItem('userData')); /** * This function is used for demo purpose route navigation @@ -25,9 +25,9 @@ export const getUserData = () => JSON.parse(localStorage.getItem('userData')) * NOTE: If you have different pages to navigate based on user ability then this function can be useful. However, you need to update it. * @param {String} userRole Role of user */ -export const getHomeRouteForLoggedInUser = userRole => { - if (userRole === 'admin') return '/' - if (userRole === 'user') return '/' - if (userRole === 'client') return {name: 'access-control'} - return {name: 'auth-login'} -} +export const getHomeRouteForLoggedInUser = (userRole) => { + if (userRole === 'admin') return '/'; + if (userRole === 'user') return '/'; + if (userRole === 'client') return { name: 'access-control' }; + return { name: 'auth-login' }; +}; diff --git a/src/layout/MainLayout/Header/index.js b/src/layout/MainLayout/Header/index.js index b5eb4d6..a854f22 100644 --- a/src/layout/MainLayout/Header/index.js +++ b/src/layout/MainLayout/Header/index.js @@ -2,6 +2,9 @@ import PropTypes from 'prop-types'; import React ,{useState} from 'react'; +import {useDispatch} from "react-redux"; +import {useNavigate} from "react-router-dom"; + // material-ui // import { useTheme } from '@mui/material/styles'; import { @@ -28,7 +31,7 @@ import { // useMediaQuery } from '@mui/material'; - import MenuIcon from '@mui/icons-material/Menu'; +import MenuIcon from '@mui/icons-material/Menu'; // project import // import AppBarStyled from './AppBarStyled'; // import HeaderContent from './HeaderContent'; @@ -37,6 +40,7 @@ import MobileLogo from 'components/MobileLogo'; import Profile from './HeaderContent/Profile'; import "assets/style/navbarStyles.css"; import {isUserLoggedIn} from "utils/Utils"; +import { handleLogoutFunction } from 'auth/index'; // assets // import { MenuFoldOutlined,MenuOutlined } from '@ant-design/icons'; @@ -50,29 +54,71 @@ const drawerWidth = 240; function Header(props) { const { window } = props; const [mobileOpen, setMobileOpen] = useState(false); + const dispatch = useDispatch() + const navigate = useNavigate() const handleDrawerToggle = () => { setMobileOpen((prevState) => !prevState); }; + const handleLogout = async () => { + dispatch(handleLogoutFunction()); + //await handleLogoutFunction(); + navigate('/login'); + }; + + const loginContent = ( +