Files
basic-erp/apps/web/src/app/app.routes.ts
T

33 lines
1.2 KiB
TypeScript
Raw Normal View History

import type { Routes } from '@angular/router';
import { MENU } from '@basic-erp/sap-types';
import { authGuard, guestGuard, menuLoadedGuard, permissionGuard } from './core/auth/guards';
/** Una ruta por pantalla del menú; las que aún no existen muestran "no disponible". */
const screens: Routes = MENU.flatMap((m) => m.items).map((item) => ({
path: item.path.slice(1),
canActivate: [permissionGuard],
data: { path: item.path, title: item.label },
loadComponent: () => import('./features/shared/coming-soon.page').then((m) => m.ComingSoonPage),
}));
export const routes: Routes = [
{
path: 'login',
canActivate: [guestGuard],
loadComponent: () => import('./features/login/login.page').then((m) => m.LoginPage),
},
{
path: '',
canActivate: [authGuard, menuLoadedGuard],
loadComponent: () => import('./layout/main-layout').then((m) => m.MainLayout),
children: [
{ path: '', pathMatch: 'full', loadComponent: () => import('./features/home/home.page').then((m) => m.HomePage) },
{
path: 'sin-acceso',
loadComponent: () => import('./features/shared/no-access.page').then((m) => m.NoAccessPage),
},
...screens,
],
},
{ path: '**', redirectTo: '' },
];