import { Component, Input, OnChanges } from '@angular/core';
import { RouteTypeLegacy } from '@app/shared/enumerators';
import {
    FlightModel,
    Leg,
    Transfer,
    TransferLogic,
} from '@app/shared/models-legacy';

@Component({
    selector: 'transfer-inline-extended',
    templateUrl: './transfer-inline-extended.component.html',
    styleUrls: ['./transfer-inline-extended.component.scss'],
})
export class TransferInlineExtended implements OnChanges {
    constructor(private logic: TransferLogic) {}

    @Input() flight: FlightModel;
    @Input() nextFlight: FlightModel;
    @Input() leg: Leg;

    RouteType = RouteTypeLegacy;
    transfer: Transfer;

    ngOnChanges() {
        this.transfer = this.logic.getTransfer(
            this.flight,
            this.nextFlight,
            this.leg,
        );
    }
}
