diff --git a/src/components/Header.css b/src/components/Header.css new file mode 100644 index 0000000..38884aa --- /dev/null +++ b/src/components/Header.css @@ -0,0 +1,26 @@ +.navbar { + justify-content: center; +} + +.nav-link { + text-align: center; + width: 8rem !important; + margin: 0.1rem; + border-radius: 0.5rem !important; +} + +.nav-link.active { + color: #ffffff !important; + background-color: #007bff !important; + border: 1px solid #007bff; + border-radius: 0.5rem; + padding: 0.5rem 1rem; + text-decoration: none; +} + +.nav-item .btn-primary.active { + color: #ffffff !important; + background-color: #007bff !important; + border: 1px solid #007bff; + border-radius: 0.25rem; +} \ No newline at end of file diff --git a/src/components/Header.jsx b/src/components/Header.jsx index 65c536d..c662dc9 100644 --- a/src/components/Header.jsx +++ b/src/components/Header.jsx @@ -1,6 +1,7 @@ import React from "react"; -import { Link, useNavigate } from "react-router-dom"; +import { Link, NavLink, useNavigate } from "react-router-dom"; import { useAuth } from "../AuthContext"; +import "./Header.css"; const Header = () => { const { isAuthenticated, logout } = useAuth(); @@ -14,8 +15,8 @@ const Header = () => { }; return ( -
-
+
+ ); }; diff --git a/src/components/RoleRoute.jsx b/src/components/RoleRoute.jsx index a219c39..bff128a 100644 --- a/src/components/RoleRoute.jsx +++ b/src/components/RoleRoute.jsx @@ -4,12 +4,13 @@ import { useAuth } from "../AuthContext"; const RoleRoute = ({ allowedRoles }) => { const { isAuthenticated, role } = useAuth(); + const user = JSON.parse(localStorage.getItem("user")); if (!isAuthenticated) { return ; } - if (allowedRoles && !allowedRoles.includes(role)) { + if (allowedRoles && !allowedRoles.includes(user.role_name)) { return ; }