import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {HomeComponent} from "./pages/home/home.component";
import {LoginComponent} from "./pages/login/login.component";
import {ProfileComponent} from "./pages/profile/profile.component";
import {AuthGuard} from "./_guards";
import {EventsComponent} from "./pages/events/events.component";
import {EventDetailsComponent} from "./pages/event-details/event-details.component";
import {RegistrationsComponent} from "./pages/registrations/registrations.component";
import {RegistrationComponent} from "./pages/registration/registration.component";
import {GuestLayoutComponent} from "./layout/guest-layout/guest-layout.component";
import {SecuredLayoutComponent} from "./layout/secured-layout/secured-layout.component";
import {PasswordChangeComponent} from "./pages/password-change/password-change.component";

const routes: Routes = [

  {
    path: '',
    component: GuestLayoutComponent,
    children: [
      { path: '', component: LoginComponent, pathMatch: 'full'},
      { path: 'login', component: LoginComponent , pathMatch: 'full'}
    ]
  },
  {
    path: '',
    component: SecuredLayoutComponent,
    children: [
      { path: 'home', component: HomeComponent , pathMatch: 'full', canActivate: [AuthGuard]},
      { path: 'home/:idTrainer/:idEventType', component: HomeComponent , pathMatch: 'full' ,canActivate: [AuthGuard]},
      { path: 'logout', redirectTo: '/login' , pathMatch: 'full'},
      { path: 'profile', component: ProfileComponent, canActivate: [AuthGuard]   },
      { path: 'events', component: EventsComponent, canActivate: [AuthGuard]   },
      { path: 'event-details/:idEvent', component: EventDetailsComponent, canActivate: [AuthGuard]  , pathMatch: 'full' },
      { path: 'registrations', component: RegistrationsComponent, canActivate: [AuthGuard]  , pathMatch: 'full' },
      { path: 'registration/:idRegistration', component: RegistrationComponent,  canActivate: [AuthGuard] },
      { path: 'password-change', component: PasswordChangeComponent, canActivate: [AuthGuard]  }
    ]
  },
  { path: '**', redirectTo: '' }
];

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