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

import { WelcomePageComponent } from './welcome-page/welcome-page.component';
import { MainPageComponent } from './main-page/main-page.component'
import { MainNotApprovedPageComponent } from './instructor/pages/main-not-approved-page/main-not-approved-page.component';
import { LoginPageComponent } from './instructor/pages/login-page/login-page.component';
import { RegisterPageComponent } from './instructor/pages/register-page/register-page.component';
import { MyProfilePageComponent } from './instructor/pages/my-profile-page/my-profile-page.component';
import { EditMyProfilePageComponent } from './instructor/pages/edit-my-profile-page/edit-my-profile-page.component';
import { AllInstructorsPageComponent } from './instructor/pages/all-instructors-page/all-instructors-page.component';
import { InstructorProfilePageComponent } from './instructor/pages/instructor-profile-page/instructor-profile-page.component';
import { EditInstructorProfilePageComponent } from './instructor/pages/edit-instructor-profile-page/edit-instructor-profile-page.component';
import { CoursesPageComponent } from './courses/pages/courses-page/courses-page.component';
import { MyCoursesPageComponent } from './courses/pages/my-courses-page/my-courses-page.component';
import { NewCoursePageComponent } from './courses/pages/new-course-page/new-course-page.component';
import { NotificationPagesComponent } from './instructor/pages/notification-pages/notification-pages.component';
import { NotAuthorizedPageComponent } from './error/not-authorized-page/not-authorized-page.component';
import { PageNotFoundComponent } from './page-not-found/page-not-found.component';
import { AllThemesPageComponent } from './course-themes/pages/all-themes-page/all-themes-page.component';
import { AllSchoolsPageComponent } from './instructor/pages/all-schools-page/all-schools-page.component';
import { CourseDetailPageComponent } from './courses/pages/course-detail-page/course-detail-page.component';
import { EditCoursePageComponent } from './courses/pages/edit-course-page/edit-course-page.component';
import { NewThemePageComponent } from './course-themes/pages/new-theme-page/new-theme-page.component';
import { EditThemePageComponent } from './course-themes/pages/edit-theme-page/edit-theme-page.component';
import { SchoolDetailPageComponent } from './school/pages/school-detail-page/school-detail-page.component';
import { EditSchoolDetailPageComponent } from './school/pages/edit-school-detail-page/edit-school-detail-page.component';
import { SchoolLoginPageComponent } from './school/pages/school-login-page/school-login-page.component';
import { SchoolMainPageComponent } from './school/pages/school-main-page/school-main-page.component';
import { EditSchoolProfilePageComponent } from './school/pages/edit-school-profile-page/edit-school-profile-page.component';
import { SchoolProfilePageComponent } from './school/pages/school-profile-page/school-profile-page.component';
import { SchoolCoursesPageComponent } from './school/pages/school-courses-page/school-courses-page.component';
import { EnlistCoursePageComponent } from './school/pages/enlist-course-page/enlist-course-page.component';
import { SchoolRegisterPageComponent } from './school/pages/school-register-page/school-register-page.component';
import { SchoolQuestionnairePageComponent } from './school/pages/school-questionnaire-page/school-questionnaire-page.component';
import { MyFundPageComponent } from './funds/pages/my-fund-page/my-fund-page.component';
import { InstructorPayoutsPageComponent } from './instructor/pages/instructor-payouts-page/instructor-payouts-page.component';
import { DietSummaryPageComponent } from './courses/pages/diet-summary-page/diet-summary-page.component';
import { AccommodationSummaryPageComponent } from './courses/pages/accommodation-summary-page/accommodation-summary-page.component';
import { MainBlockedPageComponent } from './instructor/pages/main-blocked-page/main-blocked-page.component';

import { NotLoggedGuard } from './guards/not-logged.guard';
import { InstructorGuard } from './guards/instructor.guard';
import { SchoolGuard } from './guards/school.guard';

import * as Globals from './globals';

const routes: Routes = [
  { path: '', component: WelcomePageComponent, canActivate: [NotLoggedGuard] },
  { path: Globals.pages.instructorLogin.path, component: LoginPageComponent, canActivate: [NotLoggedGuard] },
  { path: Globals.pages.instructorRegister.path, component: RegisterPageComponent, canActivate: [NotLoggedGuard] },
  { path: Globals.pages.schoolLogin.path, component: SchoolLoginPageComponent, canActivate: [NotLoggedGuard] },
  { path: Globals.pages.schoolRegister.path, component: SchoolRegisterPageComponent, canActivate: [NotLoggedGuard] },
  { path: Globals.pages.main.path, component: MainPageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'instruktor' }  },
  { path: Globals.pages.mainNotApproved.path, component: MainNotApprovedPageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'cekatel' }  },
  { path: Globals.pages.mainBlocked.path, component: MainBlockedPageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'blokovany' }  },
  { path: Globals.pages.myProfile.path, component: MyProfilePageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'cekatel' }  },
  { path: Globals.pages.editMyProfile.path, component: EditMyProfilePageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'cekatel' }  },
  { path: Globals.pages.courses.path, component: CoursesPageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'instruktor' }  },
  { path: Globals.pages.myCourses.path, component: MyCoursesPageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'instruktor' } },
  { path: Globals.pages.courseDetail.path + '/:id', component: CourseDetailPageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'instruktor' }  },
  { path: Globals.pages.courseEdit.path + '/:id', component: EditCoursePageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'zamestnanec' }  },
  { path: Globals.pages.newCourse.path, component: NewCoursePageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'zamestnanec' }  },
  { path: Globals.pages.instructors.path, component: AllInstructorsPageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'zamestnanec' } },
  { path: Globals.pages.instructorProfile.path + '/:id', component: InstructorProfilePageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'zamestnanec' }  },
  //{ path: 'profil-instruktora/:id', component: InstructorProfilePageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'zamestnanec' }  },
  { path: Globals.pages.editInstructorProfile.path + '/:id', component: EditInstructorProfilePageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'zamestnanec' }  },
  { path: Globals.pages.notifications.path, component: NotificationPagesComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'zamestnanec' } },
  { path: Globals.pages.allThemes.path, component: AllThemesPageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'zamestnanec' } },
  { path: Globals.pages.newTheme.path, component: NewThemePageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'zamestnanec' } },
  { path: Globals.pages.editTheme.path + '/:id', component: EditThemePageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'zamestnanec' } },
  { path: Globals.pages.allSchools.path, component: AllSchoolsPageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'zamestnanec' } },
  { path: Globals.pages.schoolDetail.path + '/:id', component: SchoolDetailPageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'zamestnanec' } },
  { path: Globals.pages.editSchoolDetail.path + '/:id', component: EditSchoolDetailPageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'zamestnanec' } },
  { path: Globals.pages.myFund.path, component: MyFundPageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'instruktor' } },
  { path: Globals.pages.payouts.path, component: InstructorPayoutsPageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'zamestnanec' } },
  { path: Globals.pages.diets.path, component: DietSummaryPageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'zamestnanec' } },
  { path: Globals.pages.accommondations.path, component: AccommodationSummaryPageComponent, canActivate: [InstructorGuard], data: { minimalAllowed: 'zamestnanec' } },
  { path: Globals.pages.mainSchool.path, component: SchoolMainPageComponent, canActivate: [SchoolGuard] },
  { path: Globals.pages.schoolProfile.path, component: SchoolProfilePageComponent, canActivate: [SchoolGuard] },
  { path: Globals.pages.editSchoolProfile.path, component: EditSchoolProfilePageComponent, canActivate: [SchoolGuard] },
  { path: Globals.pages.schoolCourses.path, component: SchoolCoursesPageComponent, canActivate: [SchoolGuard] },
  { path: Globals.pages.enlistCourse.path, component: EnlistCoursePageComponent, canActivate: [SchoolGuard] },
  { path: Globals.pages.schoolQuestionnaire.path + '/:id', component: SchoolQuestionnairePageComponent, canActivate: [SchoolGuard] },
  { path: Globals.pages.notAuthorized.path, component: NotAuthorizedPageComponent },
  { path: Globals.pages.notFound.path, component: PageNotFoundComponent },
  { path: '**', component: PageNotFoundComponent },
];

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