import { Injectable } from '@angular/core';
import { MatDialog, MatDialogRef } from '@angular/material';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { ReservationPassengerDialogComponent } from '../reservation-passenger-dialog.component';


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

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

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