import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';

@Component({
    selector: 'app-name-server',
    templateUrl: './name-server.component.html',
    styleUrls: ['./name-server.component.css'],
    standalone: false
})
export class NameServerComponent implements OnInit {

  @ViewChild('nameServerForm') nameServerForm: NameServerComponent;

  domainId: number = 0;
  organisationId: number = 0;
  applicationId: string = '';
  nameServerLength:number=0;
  constructor(private router: Router,
    private acRoute: ActivatedRoute
  ){
    this.organisationId = this.router.getCurrentNavigation().extras?.state['organisationId'] | 0;
    this.domainId = this.router.getCurrentNavigation().extras?.state['domainId'] | 0;
    this.applicationId = this.router.getCurrentNavigation().extras?.state['applicationId'];
    this.nameServerLength=this.router.getCurrentNavigation().extras?.state['nameServerLength']?this.router.getCurrentNavigation().extras?.state['nameServerLength']:0
   // console.log(this.organisationId);
   // console.log(this.domainId);
   // console.log(this.applicationId);
   
  }

  paramValue: any | null = '';
  ngOnInit(): void {
    this.acRoute.queryParams.subscribe(params => {
      const paramValue = params['domainId']; // Extract query param
     // console.log('Query Param:', paramValue);

      if (paramValue && !isNaN(+paramValue)) {  // Ensures it's a number
        this.paramValue = +paramValue;  // Convert to number
       // console.log('Parsed Query Param:', this.paramValue);
      } else {
       // console.log('Invalid or missing query param');
      }
    });
  }

}
