import { Component, Input } from "@angular/core";
import { OnboardServiceModel } from '@shared/models-legacy/onboard-service.model';

@Component({
    selector: 'flight-details-services',
    templateUrl: './flight-details-services.component.html',
    styleUrls: ['./flight-details-services.component.scss']
})
export class FlightDetailsServicesComponent {
    @Input() onBoardServices: OnboardServiceModel[];

    serviceIconSrc = [
        { id: 1, src: 'assets/img/service-and-food-icons/shopping.svg' },
        { id: 2, src: 'assets/img/service-and-food-icons/space.svg' },
        { id: 3, src: 'assets/img/service-and-food-icons/taxi.svg' },
        { id: 4, src: 'assets/img/service-and-food-icons/wifi.svg' },
        { id: 5, src: 'assets/img/service-and-food-icons/gsm.svg' },
        { id: 6, src: 'assets/img/service-and-food-icons/entertaintment.svg' },
        { id: 7, src: 'assets/img/service-and-food-icons/entertaintment.svg' },
        { id: 8, src: 'assets/img/service-and-food-icons/seat_reservation.svg' },
    ];

    getServiceUrl(id) {
        const service = this.onBoardServices.find((service) => service.id == id);

        return service?.url || 'https://aeroflot.ru';
    }

    getServiceIconSrc(id) {
        const serviceIcon = this.serviceIconSrc.find((i) => i.id == id);
        if (serviceIcon) {
            return serviceIcon.src;
        } else {
            return 'assets/img/service-and-food-icons/comfort-plus.svg';
        }
    }
}
