{\n let originLocationCode: string | undefined;\n let destinationLocationCode: string | undefined;\n let originCountry: string | undefined;\n let destinationCountry: string | undefined;\n\n if (!isCountryCode(flightParams.origin)) {\n originLocationCode = flightParams.origin;\n destinationLocationCode = flightParams.destination ? flightParams.destination : undefined;\n } else {\n originCountry = flightParams.origin;\n destinationCountry = flightParams.destination ? flightParams.destination : undefined;\n }\n\n return this.ondMarketingOffersService.fetchLocationPairs({\n origin: originLocationCode,\n destination: destinationLocationCode,\n originCountry,\n destinationCountry,\n });\n }\n\n private overrideBreadcrumb(ondStream$: Observable<[FlightPair, OndLocationsResponse]>) {\n this.subscriptions.add(\n combineLatest([\n this.navigationMenuService.deprecatedDestinationsBreadcrumbItem$,\n this.navigationMenuService.currentPath$,\n this.languageService.translate('flightsTo'),\n ondStream$,\n ]).subscribe(([dst, cp, totr, [flightParams, locationData]]) => {\n if (isDestinationCode(flightParams.origin) && isDestinationCode(flightParams.destination)) {\n const destinationLocationData = locationData[flightParams.destination] as OndLocationData;\n const originLocationData = locationData[flightParams.origin] as OndLocationData;\n const countryCrumb: BreadcrumbItem = {\n title: destinationLocationData.country,\n url: destinationLocationData.countryUrl,\n };\n const destinationCrumb: BreadcrumbItem = {\n title: `${totr} ${destinationLocationData.cityName}`,\n url: destinationLocationData.destinationUrl,\n };\n const currentCrumb: BreadcrumbItem = {\n title: `${originLocationData.cityName} ${destinationLocationData.cityName}`,\n url: cp,\n };\n\n this.breadcrumbService.setBreadcrumb([dst, countryCrumb, destinationCrumb, currentCrumb]);\n } else {\n this.breadcrumbService.setBreadcrumb([dst]);\n }\n })\n );\n }\n}\n","import { Injectable } from '@angular/core';\nimport { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';\n\nimport { recurseLangParam } from '@fcom/common/utils/route-utils';\nimport { SentryLogger, RootPaths } from '@fcom/core';\nimport { isCountryCode, isDestinationCode } from '@fcom/ond-marketing-landing-core/services/utils';\n\n@Injectable()\nexport class OndMarketingLandingViewPageGuard implements CanActivate {\n constructor(\n private sentryLogger: SentryLogger,\n private router: Router\n ) {}\n\n canActivate(route: ActivatedRouteSnapshot, _state: RouterStateSnapshot): boolean {\n const lang = recurseLangParam(route);\n const originLocationCode = route.params['originLocationCode'] || '';\n const destinationLocationCode = route.params['destinationLocationCode'] || '';\n\n if (this.isInvalidRoute([originLocationCode, destinationLocationCode])) {\n return this.deny(lang);\n }\n\n return true;\n }\n\n // @TODO: check that page for origin and destination is actually valid when data is available\n private isValidCode(code: string): boolean {\n return isCountryCode(code) || isDestinationCode(code);\n }\n\n private isInvalidRoute(codes: string[]): boolean {\n const hasNoValidRoutes = codes.filter((code) => this.isValidCode(code)).length === 0;\n const hasInvalidRoute = codes.some((code) => code && !this.isValidCode(code));\n\n return hasNoValidRoutes || hasInvalidRoute;\n }\n\n private deny(lang: string): false {\n this.sentryLogger.warn('Someone tried to access OnD marketing landing page without valid flight pair parameters');\n this.router.navigateByUrl(`/${lang}/${RootPaths.OND_MARKETING_LANDING_ROOT}`, { replaceUrl: true });\n return false;\n }\n}\n","\n
\n {{ heading$ | async }}\n
\n\n \n \n\n","import { Component, OnDestroy, OnInit, Renderer2 } from '@angular/core';\nimport { ActivatedRoute } from '@angular/router';\n\nimport { Observable, Subscription } from 'rxjs';\nimport { switchMap } from 'rxjs/operators';\n\nimport { LanguageService } from '@fcom/ui-translate';\nimport { unsubscribe } from '@fcom/core/utils';\nimport { PageMetaService } from '@fcom/common/services';\nimport { OndDataStream, OndPageType, OndPairEnhancedResponse } from '@fcom/ond-marketing-landing-core/interfaces';\nimport { OndMarketingOffersService } from '@fcom/ond-marketing-landing-core/services';\nimport { getCurrentCountry } from '@fcom/ond-marketing-landing-core/services/utils';\n\n@Component({\n selector: 'fin-ond-marketing-listing',\n templateUrl: 'ond-marketing-listing.component.html',\n})\nexport class OndMarketingListingComponent implements OnInit, OnDestroy {\n heading$: Observable;\n ondStream$: Observable;\n pairs$: Observable;\n ondPageType: OndPageType = OndPageType.LISTING;\n private subscriptions: Subscription = new Subscription();\n\n constructor(\n readonly route: ActivatedRoute,\n private ondMarketingOffersService: OndMarketingOffersService,\n private languageService: LanguageService,\n private pageMetaService: PageMetaService,\n private renderer: Renderer2\n ) {}\n\n ngOnInit(): void {\n this.pageMetaService.moveMetaAndLinksToHead([], this.renderer);\n\n if (this.languageService.langValue === 'en') {\n this.pairs$ = this.ondMarketingOffersService.fetchLocationPairs({\n originCountry: 'fi',\n lang: this.languageService.langValue,\n });\n } else {\n this.pairs$ = this.ondMarketingOffersService.fetchLocationPairs({\n originCountry: getCurrentCountry(this.languageService.langValue),\n lang: this.languageService.langValue,\n });\n }\n\n this.heading$ = this.route.data.pipe(\n switchMap((data) => {\n return this.languageService.translate(`ondMarketing.ribbon.${data.key}`);\n })\n );\n }\n\n ngOnDestroy() {\n this.subscriptions = unsubscribe(this.subscriptions);\n }\n}\n","import { NgModule } from '@angular/core';\nimport { RouterModule, Routes } from '@angular/router';\n\nimport { HeaderComponent, NavigationModule } from '@fcom/common/components';\nimport { BaseLayoutComponent, BaseLayoutModule } from '@fcom/common/components/base-layout';\nimport { CmsModule, CmsFooterComponent } from '@fcom/cms/components';\nimport { OndMarketingRoutesPath } from '@fcom/ond-marketing-landing-core';\n\nimport { OndMarketingLandingComponent } from './components/ond-marketing-landing.component';\nimport { OndMarketingLandingViewPageGuard } from './services/ond-marketing-landing-view-page.guard';\nimport { OndMarketingListingComponent } from './components/ond-marketing-listing.component';\n\nexport const ondMarketingLandingRoutes: Routes = [\n {\n path: '',\n component: BaseLayoutComponent,\n children: [\n { path: '', component: HeaderComponent, outlet: 'header' },\n {\n path: `${OndMarketingRoutesPath.CITY_TO_CITY}`,\n component: OndMarketingListingComponent,\n data: { key: 'cityToCity' },\n },\n {\n path: `${OndMarketingRoutesPath.CITY_TO_CITY}/:originLocationCode/:destinationLocationCode`,\n component: OndMarketingLandingComponent,\n canActivate: [OndMarketingLandingViewPageGuard],\n },\n {\n path: `${OndMarketingRoutesPath.CITY_TO_CITY}/:originLocationCode/:destinationLocationCode/:ignoredSEOTitle`,\n component: OndMarketingLandingComponent,\n canActivate: [OndMarketingLandingViewPageGuard],\n },\n {\n path: `${OndMarketingRoutesPath.COUNTRY_TO_COUNTRY}`,\n component: OndMarketingListingComponent,\n data: { key: 'countryToCountry' },\n },\n {\n path: `${OndMarketingRoutesPath.COUNTRY_TO_COUNTRY}/:originLocationCode/:destinationLocationCode`,\n component: OndMarketingLandingComponent,\n canActivate: [OndMarketingLandingViewPageGuard],\n },\n {\n path: `${OndMarketingRoutesPath.COUNTRY_TO_COUNTRY}/:originLocationCode/:destinationLocationCode/:ignoredSEOTitle`,\n component: OndMarketingLandingComponent,\n canActivate: [OndMarketingLandingViewPageGuard],\n },\n {\n path: `${OndMarketingRoutesPath.FROM_COUNTRY}`,\n component: OndMarketingListingComponent,\n data: { key: 'fromCountry' },\n },\n {\n path: `${OndMarketingRoutesPath.FROM_COUNTRY}/:originLocationCode`,\n component: OndMarketingLandingComponent,\n canActivate: [OndMarketingLandingViewPageGuard],\n },\n {\n path: `${OndMarketingRoutesPath.FROM_COUNTRY}/:originLocationCode/:ignoredSEOTitle`,\n component: OndMarketingLandingComponent,\n canActivate: [OndMarketingLandingViewPageGuard],\n },\n {\n path: `${OndMarketingRoutesPath.FROM}`,\n component: OndMarketingListingComponent,\n data: { key: 'from' },\n },\n {\n path: `${OndMarketingRoutesPath.FROM}/:originLocationCode`,\n component: OndMarketingLandingComponent,\n canActivate: [OndMarketingLandingViewPageGuard],\n },\n {\n path: `${OndMarketingRoutesPath.FROM}/:originLocationCode/:ignoredSEOTitle`,\n component: OndMarketingLandingComponent,\n canActivate: [OndMarketingLandingViewPageGuard],\n },\n { path: '', component: CmsFooterComponent, outlet: 'footer' },\n ],\n },\n];\n\n@NgModule({\n imports: [NavigationModule, BaseLayoutModule, CmsModule, RouterModule.forChild(ondMarketingLandingRoutes)],\n declarations: [],\n providers: [OndMarketingLandingViewPageGuard],\n exports: [RouterModule],\n})\nexport class OndMarketingLandingRouteModule {}\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\n\nimport { UiTranslateModule } from '@fcom/ui-translate';\nimport { CmsModule } from '@fcom/cms';\nimport { ComponentsModule } from '@fcom/common/components';\nimport { PipesModule } from '@fcom/common/pipes/pipes.module';\nimport {\n OndMarketingLandingCoreModule,\n OndMarketingOffersService,\n OndMarketingDataService,\n} from '@fcom/ond-marketing-landing-core';\nimport { OndMarketingListingComponent } from '@fcom/ond-marketing-landing/components/ond-marketing-listing.component';\n\nimport { OndMarketingLandingRouteModule } from './ond-marketing-landing.routes';\nimport { OndMarketingLandingComponent } from './components/ond-marketing-landing.component';\n\n@NgModule({\n imports: [\n OndMarketingLandingRouteModule,\n CommonModule,\n OndMarketingLandingCoreModule,\n UiTranslateModule,\n PipesModule,\n ComponentsModule,\n CmsModule,\n ],\n providers: [OndMarketingOffersService, OndMarketingDataService],\n declarations: [OndMarketingLandingComponent, OndMarketingListingComponent],\n exports: [OndMarketingLandingComponent],\n})\nexport class OndMarketingLandingModule {}\n"],"x_google_ignoreList":[]}