import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
import { Observable } from 'rxjs';
import { AuthConnstants } from '../config/auth-constants';
import { StorageService } from '../services/storage.service';

@Injectable({
  providedIn: 'root'
})
export class IndexGuard implements CanActivate {
  constructor(
    public storageService:StorageService, 
    private router:Router
    ){}
  canActivate(): Promise<boolean> {
    return new Promise(resolve => {
      /* this.storageService.get(AuthConnstants.AUTH).then(res => {
        if(res){
          this.router.navigate(['home']);
          resolve(false);
        }
        else{
          resolve(true);
        }
      }).catch(err =>{
        resolve(false);
      }) */
    });
  }
  
}
