import { AppState } from 'src/app/store/app.reducers';
import { RoleUtil } from './../role.util';
import { Component, Input } from '@angular/core';
import { User } from '../model/user.model';
import { Router } from '@angular/router';
import { SignOffAction } from 'src/app/auth/store/auth.actions';
import { Store } from '@ngrx/store';

@Component({
  selector: 'app-navigation',
  templateUrl: './navigation.component.html',
  styleUrls: ['./navigation.component.scss']
})
export class NavigationComponent{

  @Input() user: User;

  constructor(public roleUtil: RoleUtil, private router: Router, private appStore: Store<AppState>){}

  onLogout(){
    this.router.navigate(['/']);
    setTimeout(
      () => { this.appStore.dispatch(new SignOffAction()); }, 200
    );
  }

}
