import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { CommonFunctionService } from 'src/app/core/common/common-function.service';
import { API } from 'src/app/core/services/api.service';

@Component({
  selector: 'app-verify-email',
  templateUrl: './verify-email.component.html',
})
export class VerifyEmailComponent implements OnInit {

  IPData;
  constructor(
    private route: ActivatedRoute,
    private ApiServ: API,
    public commonService: CommonFunctionService,
  ) { }
  ShowApprovalCard = false;
  ShowRejectedCard = false;
  ShowDeactivateCard = false;
  ShowExpiredCard = false;
  ngOnInit() {
    this.ShowApprovalCard = false;
    this.ShowRejectedCard = false;
    this.ShowDeactivateCard = false;
    this.ShowExpiredCard = false;
    this.route.queryParams.subscribe((params) => {
      this.VerifyUserEmail(params['key']);
    });
  }



  VerifyUserEmail(key_resp) {
    let obj = {
      key: key_resp,
    };
    this.ApiServ.AdminPost('/UserMachine/VerifyMachineEmail', obj).subscribe(
      (d) => {
        if (d && d.Status) {
          if (d.VerificationStatus == 'APPROVED') this.ShowApprovalCard = true;
          else if (d.VerificationStatus == 'REJECT') this.ShowRejectedCard = true;
          else this.ShowDeactivateCard = true;
        } else {
          if (!d.Status && d.Message == 'Key Expired') {
            this.ShowExpiredCard = true;
          }
        }
      }
    );
  };

}
