app.component.ts 1 KB
import { Component, OnInit } from '@angular/core';
import { Router, RouterModule, RoutesRecognized, RouterLink, RouterState, ActivatedRoute, RouterLinkActive } from '@angular/router';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
  title = 'autoservicio-axion';
  timerReposo: any;

  constructor (
    private router: Router,
  ) { }

  ngOnInit(): void {
    if (
      window.location.href !== 'http://localhost:4206/#/' &&
      window.location.href !== 'http://localhost:4206/#/comanda' &&
      window.location.href !== 'http://localhost:4206/#/pedidos-salientes'
      ) {
        this.startTimeOutInactividad();
      } else {
        console.log(window.location.href)
      }
  }

  restartTimer() {
    clearTimeout(this.timerReposo);
    this.startTimeOutInactividad();
  }

  startTimeOutInactividad() {
    setTimeout(() => {
      this.router.navigate(['cancelar-compra']);
    }, 1000);
  }
}