import { Component, OnInit } from '@angular/core';
import { IApiService } from '../../services/ApiService/ApiService';
import { Router, ActivatedRoute } from '@angular/router';

@Component({
  selector: 'mylogout',
  templateUrl: './logout.component.html',
})
export class LogoutComponent implements OnInit{

  constructor(
    private api : IApiService,
    private router: Router,
    private route: ActivatedRoute
  ){}

  ngOnInit(){
    this.api.logout().then(() => {
      this.route.queryParamMap.subscribe(params => {
        this.router.navigate([params.get('redirect')])        
      })
    })
  }
}