import { Component } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { PersonalInformationComponent } from '../components/fixed-rate-forms/personal-information/personal-information.component';

@Component({
  selector: 'app-contractor-contract-type',
  templateUrl: './contractor-contract-type.component.html',
  styleUrls: ['./contractor-contract-type.component.scss'],
})
export class ContractorContractTypeComponent {
  activeType!: number;

  constructor(public readonly dialog: MatDialog) {}

  onActiveType(type: number): void {
    this.activeType = type;
  }

  onClickNext(): void {
    let dialogRef;
    if (this.activeType === 0) {
      dialogRef = this.dialog.open(PersonalInformationComponent, {
        width: '70%',
        data: { type: 0 },
      });

      dialogRef.afterClosed().subscribe((result) => {
        console.log(`Dialog result: ${result}`);
      });
      return;
    }

    if (this.activeType === 1) {
      dialogRef = this.dialog.open(PersonalInformationComponent, {
        width: '70%',
        data: { type: 1 },
      });

      dialogRef.afterClosed().subscribe((result) => {
        console.log(`Dialog result: ${result}`);
      });
      return;
    }
  }
}
