import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { AdminGuard } from './authentication/admin.guard';
import { HomeComponent } from './home/home.component';
import { LoginComponent } from './authentication/login/login.component';
import { NotFoundComponent } from './not-found/not-found.component';
import { PasswordResetComponent } from './authentication/password-reset/password-reset.component';
import { LoggedInGuard } from './authentication/logged-in.guard';

const routes: Routes = [
  {
    path: 'admin',
    canLoad: [AdminGuard],
    canActivate: [AdminGuard],
    loadChildren: () =>
      import('./admin/admin.module').then((m) => m.AdminModule)
  },
  {
    path: 'player',
    canActivate: [LoggedInGuard],
    loadChildren: () =>
      import('./players/players.module').then((m) => m.PlayersModule)
  },
  { path: 'login', component: LoginComponent },
  { path: 'password-reset', component: PasswordResetComponent },
  { path: '/', component: HomeComponent, pathMatch: 'full' },
  { path: '', component: HomeComponent, pathMatch: 'full' },
  { path: '**', component: NotFoundComponent }
];

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