import { Routes } from '@angular/router';
import { MsalGuard } from '@azure/msal-angular';
import { roleGuard } from './core/components/ms-authentication/role.guard';

export const routes: Routes = [
  {
    path: 'home',
    loadComponent: () =>
      import('./pages/home/home.component').then(
        (m) => m.HomeComponent
      ),
    canActivate: [MsalGuard, roleGuard],
    data: {
      title: 'Home',
      roles: ['manager', 'admin'],
    },
  },
  {
    path: 'control-center',
    loadChildren: () =>
      import('./pages/control-center/dashboard-control-center.module').then(
        (m) => m.DashboardControlCenterModule
      ),
    canActivate: [MsalGuard],
    data: {
      title: 'Dashboard Leitstelle',
    },
  },
  {
    path: 'managers',
    loadChildren: () =>
      import(
        './pages/manager/avicenna-web-feature-dashboard-manager.module'
      ).then((m) => m.AvicennaWebFeatureDashboardManagerModule),
    canActivate: [MsalGuard, roleGuard],
    data: {
      title: 'Dashboard Manager',
      roles: ['manager', 'admin'],
    },
  },
  {
    path: 'accounting',
    loadChildren: () =>
      import('./pages/accounting/dashboard-accounting.module').then(
        (m) => m.DashboardAccountingModule
      ),
    canActivate: [MsalGuard, roleGuard],
    data: {
      title: 'Abrechnung',
      roles: ['manager', 'admin'],
    },
  },
  {
    path: 'tickets',
    loadChildren: () =>
      import('./pages/ticket-system/ticket-system.module').then(
        (m) => m.TicketSystemModule
      ),
    canActivate: [MsalGuard],
    data: {
      title: 'Ticketsystem',
    },
  },
  {
    path: '',
    pathMatch: 'full',
    redirectTo: 'control-center',
  },
];
