diff --git a/src/App.css b/src/App.css
index 788b373..874a035 100644
--- a/src/App.css
+++ b/src/App.css
@@ -263,6 +263,7 @@ button:hover {
justify-content: center;
align-items: center;
padding: 0 !important;
+ margin: .25rem;
}
h1.text-warning {
diff --git a/src/App.js b/src/App.js
index c2819c0..918c130 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,5 +1,10 @@
import React from "react";
-import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
+import {
+ BrowserRouter as Router,
+ Routes,
+ Route,
+ useParams,
+} from "react-router-dom";
import "bootstrap/dist/css/bootstrap.min.css";
import "bootstrap/dist/js/bootstrap.bundle.min";
@@ -20,9 +25,20 @@ import Login from "./components/Login/LoginForm";
import { PrivateRoutes, PublicRoutes } from "./models/routes";
import Guard from "./guards/route.guard";
+import Id from "./guards/id.guard";
+
+const UserGuardedRoute = ({ element, permissions, allowedId }) => {
+ const { id_usuario } = useParams();
+ return permissions === 1 || id_usuario == allowedId ? (//double equal is necessary
+ element
+ ) : (
+
+ );
+};
const App = () => {
const permissions = Guard();
+ const id = Id();
const isLoginPage = window.location.pathname === PublicRoutes.LOGIN;
const isNotFoundPage = window.location.pathname === PublicRoutes.NOTFOUND;
@@ -63,10 +79,30 @@ const App = () => {
path={`${PrivateRoutes.EDITARPROFESOR}:id_profesor`}
element={}
/>
- } />
>
)}
+ }
+ permissions={permissions}
+ allowedId={id}
+ />
+ }
+ />
+ }
+ permissions={permissions}
+ allowedId={id}
+ />
+ }
+ />
+
{permissions === 1 && ( //only have permissions = 1 you can pass
<>
{
path={PrivateRoutes.FILTERUSUARIO}
element={}
/>
- }
- />
>
)}
diff --git a/src/components/Nav/Menu.css b/src/components/Nav/Menu.css
index 99c236f..6e655a7 100644
--- a/src/components/Nav/Menu.css
+++ b/src/components/Nav/Menu.css
@@ -14,7 +14,7 @@
}
.navbar-dark .nav-link {
- color: #ffffff;
+ color: white !important;
}
.navbar-dark .nav-link:hover {
@@ -29,13 +29,10 @@
background-color: #333333;
}
-.offcanvas-body .nav-link {
- color: #ffffff;
-}
-
.offcanvas-body .nav-link:hover {
color: #cccccc;
}
+
.navbar-toggler {
border-radius: 8px;
padding: 0.25rem 0.75rem;
@@ -43,4 +40,16 @@
.ms-auto {
margin-left: auto;
+}
+
+.red{
+ background-color: rgb(193, 17, 17);
+ color: white;
+ text-decoration: none;
+}
+
+.container{
+ border: 2px solid rgb(77, 77, 77);
+ border-radius: 8px;
+ margin: 10px;
}
\ No newline at end of file
diff --git a/src/components/Nav/Menu.js b/src/components/Nav/Menu.js
index 94d4028..485184a 100644
--- a/src/components/Nav/Menu.js
+++ b/src/components/Nav/Menu.js
@@ -8,6 +8,7 @@ import JwtGuard from "../../guards/jwt.guard";
const Menu = () => {
JwtGuard();
const permissions = Guard();
+ const [id, setId] = useState(null);
const [usuario, setUsuario] = useState(null);
useEffect(() => {
@@ -21,7 +22,9 @@ const Menu = () => {
const parts = jwtToken.split(".");
const decodedPayload = JSON.parse(atob(parts[1]));
const user = decodedPayload.usuario;
+ const id = decodedPayload.id_usuario;
+ setId(id);
setUsuario(user);
};
jwtPermissions();
@@ -60,7 +63,11 @@ const Menu = () => {
aria-labelledby="offcanvasNavbarLabel"
>
-
+ (window.location.href = PrivateRoutes.INTERFACE)}
+ >
Menú