// Angular
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
// Components
import { BaseComponent } from './views/theme/base/base.component';
import { ErrorPageComponent } from './views/theme/content/error-page/error-page.component';
// Auth
import { AuthGuard } from './core/auth';

const routes: Routes = [
	{path: 'auth', loadChildren: () => import('../app/views/pages/auth/auth.module').then(m => m.AuthModule)},

	{
		path: '',
		component: BaseComponent,
		canActivate: [AuthGuard],
		children: [
			{
				path: 'inicio',
				loadChildren: () => import('../app/views/pages/dashboard/dashboard.module').then(m => m.DashboardModule)
			},
			{
				path: 'catalogos',
				loadChildren: () => import('../app/views/pages/catalogos/catalogos.module').then(m => m.CatalogosModule)
			},
			{
				path: 'servicios',
				loadChildren: () => import('../app/views/pages/servicios/servicios.module').then(m => m.ServiciosModule)
			},
			{
				path: 'agenda',
				loadChildren: () => import('../app/views/pages/agenda/agenda.module').then(m => m.AgendaModule)
			},
			{
				path: 'reportes',
				loadChildren: () => import('../app/views/pages/reportes/reportes.module').then(m => m.ReportesModule)
			},
			{
				path: 'encuesta',
				loadChildren: () => import('../app/views/pages/encuesta/encuesta.module').then(m => m.EncuestaModule)
			},
			{
				path: 'error/403',
				component: ErrorPageComponent,
				data: {
					type: 'error-v6',
					code: 403,
					title: '403... Access forbidden',
					desc: 'Looks like you don\'t have permission to access for requested page.<br> Please, contact administrator'
				}
			},
			{path: 'error/:type', component: ErrorPageComponent},
			{path: '', redirectTo: 'inicio', pathMatch: 'full'},
			{path: '**', redirectTo: 'inicio', pathMatch: 'full'}
		]
	},
	{path: '', redirectTo: 'inicio', pathMatch: 'full'},
	{path: '**', redirectTo: 'error/403', pathMatch: 'full'},
];

@NgModule({
	imports: [
		RouterModule.forRoot(routes)
	],
	exports: [RouterModule]
})
export class AppRoutingModule {
}
