import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

@Component({
  selector: 'byte-step-summary-reservation',
  templateUrl: './step-summary-reservation.component.html',
  styleUrls: ['./step-summary-reservation.component.scss']
})
export class StepSummaryReservationComponent implements OnInit  {

  public displayedColumns: string[] = ['id', 'airportOriginName', 'airportDestinationName', 'departureDate', 'arrivalDate'];

  @Input()
  public flight: any;

  @Input()
  public passenger: any;

  @Input()
  public travelClass: string;

  @Input()
  public ticketType: string;

  @Output()
  public onSave: EventEmitter<void> = new EventEmitter();

  public mode: string;

  getDisabledConditions(): boolean {
    return this.mode !== 'new';
  }

  constructor(private activatedRoute: ActivatedRoute) { }

  ngOnInit(): void {
    this.activatedRoute.params.subscribe(params => this.mode = params.mode);
  }

  get flightType(): string | null {
    return this.flight ? this.flight.length > 1 ? 'Con escalas' : 'Directo' : null;
  }

  onEmitSave(): void {
    this.onSave.emit();
  }
}
