import { Component, Inject } from '@angular/core';
import { MatDialog, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { PaymantConfigComponent } from '../../pay-as-you-go/paymant-config/paymant-config.component';
import { PaymentRateComponent } from '../payment-rate/payment-rate.component';

@Component({
  selector: 'app-personal-information',
  templateUrl: './personal-information.component.html',
  styleUrls: ['./personal-information.component.scss'],
})
export class PersonalInformationComponent {
  constructor(
    public readonly dialog: MatDialog,
    @Inject(MAT_DIALOG_DATA) public data: { type: number }
  ) {}
  onOpenPaymentRate(): void {
    let dialogRef;
    if (this.data.type === 0) {
      dialogRef = this.dialog.open(PaymentRateComponent, {
        width: '70%',
      });
      dialogRef.afterClosed().subscribe((result) => {
        console.log(`Dialog result: ${result}`);
      });
    } else {
      dialogRef = this.dialog.open(PaymantConfigComponent, {
        width: '50%',
      });
      dialogRef.afterClosed().subscribe((result) => {
        console.log(`Dialog result: ${result}`);
      });
    }
  }
}
