import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { CanActivateArrivalSearch } from './guards/can-activate-arrival-search';
import { CanActivateDepartureSearch } from './guards/can-activate-departure-search';
import { CanActivateOnlineBoardDetails } from './guards/can-activate-details';
import { CanActivateRouteSearch } from './guards/can-activate-route-search';
import { CanActivateFlightNumberSearch } from './guards/can-activate-flight-number-search';
import { ArrivalSearchPageComponent } from './pages/search/arrival/arrival-search-page.component';
import { DepartureSearchPageComponent } from './pages/search/departure/departure-search-page.component';
import { OnlineBoardFlightDetailsPageComponent } from './pages/flight-details/flight-details-page.component';
import { FlightNumberSearchPageComponent } from './pages/search/flight-number-search/flight-number-search-page.component';
import { RouteSearchPageComponent } from './pages/search/route-search/route-search-page.component';
import { OnlineBoardStartPageComponent } from './pages/start/online-board-start-page.component';
import { OnlineBoardDetailsBreadCrumbsResolver } from './resolvers/bread-crumbs/details-bread-crumbs.resolver';
import { OnlineBoardRouteSearchBreadCrumbsResolver } from './resolvers/bread-crumbs/route-search-bread-crumbs.resolver';
import { OnlineBoardArrivalUrlParamsResolver } from './resolvers/url-params/arrival-url-params.resolver';
import { OnlineBoardDepartureUrlParamsResolver } from './resolvers/url-params/departure-url-params.resolver';
import { OnlineBoardDetailsUrlParamsResolver } from './resolvers/url-params/details-url-params.resolver';
import { OnlineBoardFlightNumberUrlParamsResolver } from './resolvers/url-params/flight-number-url-params.resolver';
import { OnlineBoardRequestDataResolver } from './resolvers/request-data.resolver';
import { OnlineBoardRouteUrlParamsResolver } from './resolvers/url-params/route-url-params.resolver';

const routes: Routes = [
    {
        path: 'flight/:params', // params are {flightNumber}-{flightDate}
        component: FlightNumberSearchPageComponent,
        canActivate: [CanActivateFlightNumberSearch],
        resolve: {
            urlParams: OnlineBoardFlightNumberUrlParamsResolver,
            breadcrumbs: OnlineBoardRouteSearchBreadCrumbsResolver,
        },
    },
    {
        path: 'departure/:params', // params are {departure}-{flightDate}-{timeFrom}{timeTo}
        component: DepartureSearchPageComponent,
        canActivate: [CanActivateDepartureSearch],
        resolve: {
            urlParams: OnlineBoardDepartureUrlParamsResolver,
            breadcrumbs: OnlineBoardRouteSearchBreadCrumbsResolver,
        },
    },
    {
        path: 'arrival/:params', // params are {arrival}-{flightDate}-{timeFrom}{timeTo}
        component: ArrivalSearchPageComponent,
        canActivate: [CanActivateArrivalSearch],
        resolve: {
            urlParams: OnlineBoardArrivalUrlParamsResolver,
            breadcrumbs: OnlineBoardRouteSearchBreadCrumbsResolver,
        },
    },
    {
        path: 'route/:params', // params are {departure}-{arrival}-{flightDate}-{timeFrom}{timeTo}
        component: RouteSearchPageComponent,
        canActivate: [CanActivateRouteSearch],
        resolve: {
            urlParams: OnlineBoardRouteUrlParamsResolver,
            breadcrumbs: OnlineBoardRouteSearchBreadCrumbsResolver,
        },
    },
    {
        path: ':params', // params are {flightNumber}-{flightDate}
        component: OnlineBoardFlightDetailsPageComponent,
        canActivate: [CanActivateOnlineBoardDetails],
        resolve: {
            urlParams: OnlineBoardDetailsUrlParamsResolver,
            requestData: OnlineBoardRequestDataResolver,
            breadcrumbs: OnlineBoardDetailsBreadCrumbsResolver,
        },
    },
    {
        path: '',
        component: OnlineBoardStartPageComponent,
    },
];

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