import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { FlightModel } from '@shared/models-legacy/flight.model';
import { ViewType } from '@app/shared/enumerators/flight-request-type.enum';
import { getFlights } from '@app/shared/models-legacy';
import { RouteTypeLegacy } from '@app/shared/enumerators';

@Component({
    selector: 'schedule-details-header',
    templateUrl: './schedule-details-header.component.html',
    styleUrls: ['./schedule-details-header.component.scss'],
})
export class ScheduleDetailsHeaderComponent implements OnChanges {
    @Input() flight: FlightModel;
    RouteType = RouteTypeLegacy;
    ViewType = ViewType;
    flights: FlightModel[];
    isConnecting: boolean;

    ngOnChanges(changes: SimpleChanges) {
        if (this.flight && 'flight' in changes) {
            this.flights = getFlights(this.flight);
            this.isConnecting = this.flight.routeType === RouteTypeLegacy.Connecting;
        }
    }
}
