import { Component, Inject, ViewEncapsulation } from '@angular/core';
import { Router } from '@angular/router';
import {
    FlightRequestType,
    ViewType,
} from '@shared/enumerators/flight-request-type.enum';
import { AppSettings } from '@shared/models-legacy';
import { APP_SETTINGS } from '@shared/services';
import {
    ISearchHistoryItem,
    SearchHistoryService,
} from '@shared/services/history/search-history.service';

@Component({
    selector: 'search-history',
    templateUrl: './search-history.component.html',
    styleUrls: ['./search-history.component.scss'],
    encapsulation: ViewEncapsulation.None,
})
export class SearchHistoryComponent {
    ViewType = ViewType;
    FlightRequestType = FlightRequestType;

    constructor(
        @Inject(APP_SETTINGS) public settings: AppSettings,
        private historyService: SearchHistoryService,
        private router: Router,
    ) {}

    get historyItems() {
        return this.historyService.items;
    }

    openHistoryUrl(item: ISearchHistoryItem) {
        return this.router.navigateByUrl(item.url);
    }
}
