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


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

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

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