Refactor navbar component for improved readability and consistency
This commit is contained in:
+19
-10
@@ -4,14 +4,13 @@ import Link from 'next/link';
|
||||
import { usePathname } from 'next/navigation';
|
||||
|
||||
type NavChild = {
|
||||
href: string; // siempre string
|
||||
href: string; // siempre string
|
||||
label: string;
|
||||
};
|
||||
|
||||
type NavItem =
|
||||
| { href: string; label: string } // items normales
|
||||
| { label: string; children: NavChild[] } // items con submenu
|
||||
|
||||
| { href: string; label: string } // items normales
|
||||
| { label: string; children: NavChild[] }; // items con submenu
|
||||
|
||||
const Navbar: React.FC = () => {
|
||||
const pathname = usePathname();
|
||||
@@ -26,7 +25,10 @@ const Navbar: React.FC = () => {
|
||||
label: 'Carga Masiva',
|
||||
children: [
|
||||
{ href: '/user/eventos/carga_masiva', label: 'Carga Masiva Eventos' },
|
||||
{ href: '/user/eventos/carga_masiva_banner', label: 'Carga Masiva Imagenes' },
|
||||
{
|
||||
href: '/user/eventos/carga_masiva_banner',
|
||||
label: 'Carga Masiva Imagenes',
|
||||
},
|
||||
],
|
||||
},
|
||||
{ href: '/user/usuarios', label: 'Usuarios' },
|
||||
@@ -39,7 +41,8 @@ const Navbar: React.FC = () => {
|
||||
{ href: '/login', label: 'Cerrar sesión' },
|
||||
];
|
||||
|
||||
const navItems = tipo_usuario === 'administrador' ? navItemsAdmin : navItemsUser;
|
||||
const navItems =
|
||||
tipo_usuario === 'administrador' ? navItemsAdmin : navItemsUser;
|
||||
|
||||
return (
|
||||
<nav className="navbar navbar-expand-lg navbar-dark bg-azul">
|
||||
@@ -59,7 +62,7 @@ const Navbar: React.FC = () => {
|
||||
id="offcanvasNavbar"
|
||||
aria-labelledby="offcanvasNavbarLabel"
|
||||
>
|
||||
<div className="offcanvas-header">
|
||||
<div className="offcanvas-header bg-azul text-white">
|
||||
<h5 className="offcanvas-title" id="offcanvasNavbarLabel">
|
||||
Menu
|
||||
</h5>
|
||||
@@ -70,11 +73,17 @@ const Navbar: React.FC = () => {
|
||||
aria-label="Close"
|
||||
></button>
|
||||
</div>
|
||||
<div className="offcanvas-body align-items-center justify-content-between">
|
||||
<h2 className="h5 mb-0 text-white">Sistema de Registro de Eventos</h2>
|
||||
<div className="offcanvas-body align-items-center justify-content-between bg-azul">
|
||||
<h2 className="h5 mb-0 text-white">
|
||||
Sistema de Registro de Eventos
|
||||
</h2>
|
||||
<ul className="navbar-nav gap-lg-5">
|
||||
{navItems.map((item, index) => (
|
||||
<li key={index} className="nav-item" data-bs-dismiss="offcanvas">
|
||||
<li
|
||||
key={index}
|
||||
className="nav-item"
|
||||
data-bs-dismiss="offcanvas"
|
||||
>
|
||||
{'href' in item ? (
|
||||
<Link
|
||||
className={`nav-link ${
|
||||
|
||||
Reference in New Issue
Block a user