import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges, ViewEncapsulation } from '@angular/core';
import { IFlightTime } from '@app/shared/models-legacy';

@Component({
    selector: 'time-group-legacy',
    templateUrl: './time-group-legacy.component.html',
    styleUrls: ['./time-group-legacy.component.scss'],
    changeDetection: ChangeDetectionStrategy.OnPush,
    encapsulation: ViewEncapsulation.None,
})
export class TimeGroupLegacyComponent implements OnChanges {
    @Input() description: string;
    @Input() hasOffset = false;
    @Input() times: IFlightTime; // if is not specified, resolved from station.times.actual
    @Input() baseline: IFlightTime;
    @Input() hasDate = false;
    showBaseline = false;

    ngOnChanges(changes: SimpleChanges) {
        if ('baseline' in changes && this.baseline && !this.times) {
            this.times = this.baseline;
        }

        this.showBaseline = !this.hasDate && this.baseline && this.times.utc != this.baseline.utc;
    }
}
