<script>
const $menuContainer = document.getElementById('menu')
async function renderMenu(ruta, $container){
const menu = await getData(ruta);
if(menu){
generateMenuTemplate($container, menu);
}else{
ToastError('No hay datos para generar el Menú vertical')
}
}
function generateMenuTemplate($container, menu){
$container.innerHTML ="";
menu.forEach( (pg)=>{
let link =``;
link +=`<li class="nav-item">`;
link +=`
<a href="#" class="nav-link">`
if(pg['modulo'][0]['icono']!= null){
link += `<i class="nav-icon ${pg['modulo'][0]['icono']}"></i>`
}else{
link += `<i class="nav-icon fas fa-tachometer-alt"></i>`
}
link +=`
<p style="font-size: 13px;">
${pg['modulo'][0]['nombre']}
</p>
<i class="flecha"></i>
</a>
<ul class="nav nav-treeview">
<li class="nav-item" style="padding-left: 0.5rem;font-size: 13px;">
`;
for(let i=1; i < pg['modulo'].length;i++){
if(pg['modulo'][i]['menu'] != 'Perfil' && pg['modulo'][i]['menu'] != 'Cambiar contraseña'){
link += `
<a href="${pg['modulo'][i]['url']}" class="nav-link">`
if(pg['modulo'][i]['iconoPg'] != null){
link += `<i class="${pg['modulo'][i]['iconoPg']} nav-icon"></i>`
}else{
link += `<i class="fas fa-caret-square-right nav-icon"></i>`
}
link +=`${pg['modulo'][i]['menu']} </a>`
}
}
link += `</li></ul>`;
const element = createTemplate(link);
$container.append(element);
})
}
</script>