import { Component, OnInit } from '@angular/core';
import {ContactService} from '../contact.service';
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Route } from '@angular/router/src/config';

@Component({
  selector: 'app-resetpwd',
  templateUrl: './resetpwd.component.html',
  styleUrls: ['./resetpwd.component.scss'],
  providers:[ContactService]
})
export class ResetpwdComponent implements OnInit {
  email:any;
  npawd:any;
  cpawd:any;
  data_descip:any;
  devicess:any;

  resetpwd(){
    console.log("fisifh");
    if(this.npawd != this.cpawd){
      this.tost1("notMatch")
    }
    else{
       this.contactService.pwdreset(this.email,this.npawd).subscribe(
      
        data => {
          this.devicess = data 
          this.tost1("Match")
        

     
      
        }); 
    }
  }
  tost1(divid){
    if(divid == "notMatch"){
      this.data_descip = "New Password and Re enter Password do not match";
      launch_toast();
    }
   else if(divid == "Match"){
    this.data_descip = "Password Succesfully Reset";
    launch_toast();
    this.router.navigateByUrl("login");
   }
    
      function launch_toast() {
       // console.log(divid);
        var x = document.getElementById("toast")
        //console.log(x);
        x.className = "show";
        setTimeout(function(){ x.className = x.className.replace("show", ""); }, 2500);
    }
     }
  constructor(private contactService:ContactService,private router: Router) { }

  ngOnInit() {
    
  }

}
