import { createRouter, createWebHashHistory } from 'vue-router' import { hasPermission } from '@Plugins/RolePermission'; import examples from './Examples'; function can(next, can) { if (!hasPermission(can)) { next({ name: '404' }); } else { next(); } } const router = createRouter({ history: createWebHashHistory(import.meta.env.BASE_URL), routes: [ { path: '/', component: () => import('@Layouts/AppLayout.vue'), name: 'root', meta: { title: 'Inicio', icon: 'home', }, redirect: '/dashboard', children: [ { path: '', name: 'index', redirect: '/dashboard' }, { path: 'dashboard', name: 'dashboard.index', component: () => import('@Pages/Dashboard/Employee.vue'), meta: { title: 'Dashboard', icon: 'grid_view', } }, { path: 'vacations', name: 'vacations', meta: { title: 'Vacaciones', icon: 'calendar_month', }, children: [ { path: '', name: 'vacations.index', component: () => import('@Pages/Vacations/Employee/Index.vue'), }, { path: 'create', name: 'vacations.create', component: () => import('@Pages/Vacations/Employee/Create.vue'), } ] }, { path: 'profile', name: 'profile.show', component: () => import('@Pages/Profile/Show.vue'), meta: { title: 'Perfil', icon: 'person', } }, { path: 'profile/notifications', name: 'profile.notifications.index', component: () => import('@Pages/Profile/Notifications/Index.vue'), meta: { title: 'Notificaciones', icon: 'notifications', } }, ], }, { path: '/coordinator', name: 'coordinator', component: () => import('@Layouts/CoordinatorLayout.vue'), meta: { title: 'Inicio', icon: 'home', }, redirect: '/coordinator/dashboard', children: [ { path: 'dashboard', name: 'coordinator.dashboard', component: () => import('@Pages/Dashboard/Coordinator.vue'), meta: { title: 'Dashboard', icon: 'grid_view', }, redirect: '/coordinator/dashboard', children: [ { path: '', name: 'coordinator.dashboard.index', component: () => import('@Pages/Dashboard/Coordinator.vue'), } ] }, { path: 'vacations', name: 'vacations.coordinator', meta: { title: 'Vacaciones', icon: 'calendar_month', }, children: [ { path: '', name: 'vacations.coordinator.index', component: () => import('@Pages/Vacations/Coordinator/Index.vue'), } ] }, ] }, { path: '/admin', name: 'admin', component: () => import('@Layouts/AdminLayout.vue'), meta: { title: 'Inicio', icon: 'home', }, redirect: '/admin/employees', children: [ { path: 'dashboard', name: 'admin.dashboard.index', meta: { title: 'Dashboard', icon: 'grid_view', }, component: () => import('@Pages/Dashboard/Admin.vue'), }, { path: 'employees', name: 'admin.employees', meta: { title: 'Empleados', icon: 'people', }, redirect: '/admin/employees', children: [ { path: '', name: 'admin.employees.index', component: () => import('@Pages/Employees/Index.vue'), }, { path: 'academic', name: 'admin.academic.index', component: () => import('@Pages/Academic/Index.vue'), }, { path: 'security', name: 'admin.security.index', component: () => import('@Pages/Security/Index.vue'), }, { path: 'payroll', name: 'admin.payroll.index', component: () => import('@Pages/Payroll/Index.vue'), }, { path: 'additional', name: 'admin.additional.index', component: () => import('@Pages/Additional/Index.vue'), }, ] }, { path: 'vacations', name: 'admin.vacations', meta: { title: 'Vacaciones', icon: 'calendar_month', }, redirect: '/admin/vacations', children: [ { path: '', name: 'admin.vacations.index', component: () => import('@Pages/Vacations/Admin/Index.vue'), } ] }, { path: 'courses', name: 'admin.courses', meta: { title: 'Capacitaciones', icon: 'info', }, redirect: '/admin/courses', children: [ { path: '', name: 'admin.courses.index', component: () => import('@Pages/Courses/Index.vue'), }, { path: 'assignamment', name: 'admin.courses.assignamment', component: () => import('@Pages/Courses/Assignamment.vue'), }, { path: 'request', name: 'admin.courses.request', component: () => import('@Pages/Courses/Request.vue'), }, { path: 'calendar', name: 'admin.courses.calendar', component: () => import('@Pages/Courses/Calendar.vue'), }, ] }, { path: 'events', name: 'admin.events', meta: { title: 'Eventos', icon: 'info', }, redirect: '/admin/events', children: [ { path: '', name: 'admin.events.index', component: () => import('@Pages/Events/Index.vue'), }, { path: 'assignamment', name: 'admin.events.assignamment', component: () => import('@Pages/Events/Assignamment.vue'), }, { path: 'justification', name: 'admin.events.justification', component: () => import('@Pages/Events/Justification.vue'), }, { path: 'reports', name: 'admin.events.reports', component: () => import('@Pages/Events/Reports.vue'), }, ] }, { path: 'users', name: 'admin.users', meta: { title: 'Usuarios', icon: 'people', }, redirect: '/admin/users', children: [ { path: '', name: 'admin.users.index', beforeEnter: (to, from, next) => can(next, 'users.index'), component: () => import('@Pages/Admin/Users/Index.vue'), }, { path: 'online', name: 'admin.users.online', beforeEnter: (to, from, next) => can(next, 'users.online'), component: () => import('@Pages/Admin/Users/Online.vue') }, { path: 'create', name: 'admin.users.create', beforeEnter: (to, from, next) => can(next, 'users.create'), meta: { title: 'Crear', icon: 'add', }, component: () => import('@Pages/Admin/Users/Create.vue') }, { path: ':id/edit', name: 'admin.users.edit', beforeEnter: (to, from, next) => can(next, 'users.edit'), meta: { title: 'Editar', icon: 'edit', }, component: () => import('@Pages/Admin/Users/Edit.vue') }, { path: ':id/settings', name: 'admin.users.settings', beforeEnter: (to, from, next) => can(next, 'users.settings'), component: () => import('@Pages/Admin/Users/Settings.vue'), meta: { title: 'Configuración', icon: 'settings', }, } ] }, { path: 'roles', name: 'admin.roles', meta: { title: 'Roles', icon: 'license', }, redirect: '/admin/roles', children: [ { path: '', name: 'admin.roles.index', component: () => import('@Pages/Admin/Roles/Index.vue'), }, { path: 'create', name: 'admin.roles.create', component: () => import('@Pages/Admin/Roles/Create.vue'), meta: { title: 'Crear', icon: 'add', }, }, { path: ':id/edit', name: 'admin.roles.edit', component: () => import('@Pages/Admin/Roles/Edit.vue'), meta: { title: 'Editar', icon: 'edit', }, } ] }, { path: 'activities', name: 'admin.activities', meta: { title: 'Historial de acciones', icon: 'event', }, redirect: '/admin/activities', children: [ { path: '', name: 'admin.activities.index', beforeEnter: (to, from, next) => can(next, 'activities.index'), component: () => import('@Pages/Admin/Activities/Index.vue') } ] }, { path: 'maquetador', name: 'admin.maquetador', meta: { title: 'Maquetador de Documentos', icon: 'documents', }, redirect: '/admin/maquetador', children: [ { path: '', name: 'admin.maquetador.index', component: () => import('@Pages/Maquetador/Index.vue'), }, ] }, { path: 'templates', name: 'admin.templates.index', meta: { title: 'Plantillas', icon: 'templates', }, component: () => import('@Pages/Templates/Form.vue'), }, ] }, { path: '/changelogs', component: () => import('@Layouts/AppLayout.vue'), children: [ { path: '', name: 'changelogs.app', component: () => import('@Pages/Changelogs/App.vue') }, { path: 'core', name: 'changelogs.core', component: () => import('@Pages/Changelogs/Core.vue') } ] }, { path: '/auth', component: () => import('@Holos/Layout/Auth.vue'), children: [ { path: '', name: 'auth.index', component: () => import('@Pages/Auth/Login.vue') }, { path: 'forgot-password', name: 'auth.forgot-password', component: () => import('@Pages/Auth/ForgotPassword.vue') }, { path: 'reset-password', name: 'auth.reset-password', component: () => import('@Pages/Auth/ResetPassword.vue') } ] }, { path: '/:pathMatch(.*)*', name: '404', component: () => import('@Pages/Errors/404.vue') }, ...examples, ] }) export default router