import { Component, OnInit, Inject } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { BlockUI, NgBlockUI } from 'ng-block-ui';
import { AuthService } from '../../auth/auth.service';
import { RouteHandleService } from '../RouteHandle.service';
@Component({
  selector: 'app-auth-callback',
  templateUrl: './auth-callback.component.html',
  styleUrls: ['./auth-callback.component.css']
})
export class AuthCallbackComponent implements OnInit {
  @BlockUI() blockUI: NgBlockUI;
  baseu:string;
  constructor( @Inject('BASE_URL') baseUrl: string,private authService: AuthService,
   public router: Router,public routehandleservice: RouteHandleService) {
   
    this.baseu = baseUrl;
   }

  ngOnInit() {
    if(this.routehandleservice.isUrlExist())
    { 
      this.routehandleservice.showblockUi();
    }
    else
    {
      this.blockUI.start("Redirecting to Main Page");
    }
    
    console.log("AuthCallbackComponent start");
  // alert("111");
    this.authService.completeAuthentication().then(s=>
      
      {
        if(this.authService.isLoggedIn()==true) {
          
          
           location.assign(this.baseu+'/');

        }

      }
    
    
      
    );

    
  }
}
