import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { FlightStatusLegacy } from '@app/shared/enumerators';
import { statusColors } from './flight-status-colors';

@Component({
    selector: 'flight-status-icon',
    templateUrl: './flight-status-icon.component.html',
    changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FlightStatusIconComponent implements OnChanges {
    @Input() status: FlightStatusLegacy;
    @Input() isSchedule: boolean;

    color: string;

    ngOnChanges(changes: SimpleChanges): void {
        if (!changes.status) {
            return;
        }

        this.color = this.isSchedule ? statusColors[FlightStatusLegacy.scheduled] : statusColors[this.status];
    }
}
