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


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

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

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