import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { SidebarContentComponent } from './content/sidebar-content/sidebar-content.component';
import { LicensePrivacyTermsComponent } from './component/license-privacy-terms/license-privacy-terms.component';
import { authGuard } from './services/auth.guard';
import { loginGuard } from './services/login.guard';

const routes: Routes = [

 { path: 'login', loadChildren: () => import('./controls/login-control/login-control.module').then(m => m.LoginControlModule), canActivate: [loginGuard] },

 { path: 'license', component: LicensePrivacyTermsComponent},

  {
    path: 'main',
    component: SidebarContentComponent,
    canActivate: [
      authGuard
    ],
    children: [
      {
        path: '',
        loadChildren: () =>
          import('./controls/main-control/main-control.module').then(
            (m) => m.MainControlModule
          ),
      },
      // {
      //   path: 'report',
      //   loadChildren: () =>
      //     import('./controls/report-control/report-control.module').then(
      //       (m) => m.ReportControlModule
      //     ),
      // },
    ],
  },

  // {path: 'license' , component: LicensePrivacyTermsComponent}

  { path: '', redirectTo: 'login', pathMatch: 'full' },

  { path: '**', redirectTo: 'login' }
];

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