import {Injectable,ViewContainerRef} from "@angular/core";
import {MatDialogRef,MatDialog} from "@angular/material/dialog";
import {Observable} from "rxjs";
import {map} from "rxjs/operators";
import { ReservationVueloDialogComponent } from '../reservation-vuelo-dialog.component';


@Injectable({
  providedIn: 'root'
})
export class VueloDialogService {

  componentRef: MatDialogRef<ReservationVueloDialogComponent>;
  constructor(
    public dialog: MatDialog
  ) { }

  loadComponent(record: any, mode: string, minDate: any): Observable<boolean> {
    this.componentRef = this.dialog.open(ReservationVueloDialogComponent, {
      panelClass: 'custom-dialog',
      width: '1200px',
      disableClose: true,
      data: {
        record,
        mode,
        minDate
      }
    });
    return this.componentRef.afterClosed().pipe(map(it => {
      return it;
    }));
  }
}