import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Store } from '@ngrx/store';
import { USER } from '../../../core/models/authenticcation.model';
import { ComponentBase } from '@core/base/common-base';

@Component({
  selector: 'app-header',
  templateUrl: './header.component.html',
  styleUrls: ['./header.component.scss'],
})
export class HeaderComponent extends ComponentBase implements OnInit {
  user!: USER;

  constructor(
    private readonly router: Router,
    private readonly store: Store<{ user: { profile: USER } }>
  ) {
    super();
  }

  ngOnInit(): void {
    this.store.select('user').subscribe((res) => {
      this.user = res.profile;
    });
  }

  onOpenChat(): void {
    this.router.navigate(['/modules/chat']);
  }
}
