import { Component, OnInit , ViewChild, ElementRef } from '@angular/core';
import { Router,ActivatedRoute } from '@angular/router';
import { WebService } from './../provider/web.service';

@Component({
  selector: 'app-footer',
  templateUrl: './footer.component.html',
  styleUrls: ['./footer.component.scss']
})
export class FooterComponent implements OnInit {

  loginDetails:any;

  @ViewChild("indexLoginModal") loginModalRef: ElementRef;
  constructor(
    private router        : Router, 
    private route         : ActivatedRoute,
    public webService     : WebService,
  ) { }

  ngOnInit() {
    this.checkUserLogin();
  }

  
  checkUserLogin(){
    this.loginDetails = JSON.parse(this.webService.getLocalStorageItem('userData'));
  }

  goToPage(path,data=null){
    this.router.navigate([path],{queryParams:  data});
    document.body.scrollTop  =  document.documentElement.scrollTop  =  0;
  }
  
  signUp(){
    if(!this.loginDetails){
      this.loginModalRef.nativeElement.click();
      return false;
    }
  }

  howitwrks(){
    this.goToPage('index',{"tab":"1"});
  }


}
