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

import { authGuard } from '@guards/auth.guard';

import { LoginComponent } from './components/essentials/login/login.component';
import { LogoutComponent } from './components/essentials/logout/logout.component';

import { HomeComponent } from './components/home/home.component';

import { MatchesComponent } from './components/match/matches/matches.component';
import { MatchesIdComponent } from './components/match/matches-id/matches-id.component';
import { MatchesAddComponent } from './components/match/matches-add/matches-add.component';
import { MatchesDelComponent } from './components/match/matches-del/matches-del.component';

const routes: Routes = [
  { path: 'login', component: LoginComponent },
  { path: 'logout', component: LogoutComponent },

  { path: '', component: HomeComponent },
  { path: 'home', component: HomeComponent },

  { path: 'matches', component: MatchesComponent },
  {
    path: 'matches/add',
    component: MatchesAddComponent,
    canActivate: [authGuard],
  },
  {
    path: 'matches/del/:id',
    component: MatchesDelComponent,
    canActivate: [authGuard],
  },
  { path: 'matches/:id', component: MatchesIdComponent },
];

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