import { Component, ChangeDetectionStrategy, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { RemissionSelectors } from '../../core/store/selectors/remission.selectors';
import { Select } from '@ngxs/store';
import { ContentHeaderService } from '../../core/services/content-header.service';

@Component({
  selector: 'app-content-header',
  templateUrl: 'content-header.component.html',
  styleUrls: ['./content-header.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ContentHeaderComponent implements OnInit {
  @Select(RemissionSelectors.getRemissionActiveFilters)
  remissionFilters$: Observable<string[]>;

  showFilter$: Observable<boolean>;
  showBreadCrumbs$: Observable<boolean>;
  isFilterActive$: Observable<boolean>;
  activeModule$: Observable<'Customer' | 'Branch'>;

  constructor(private contentHeaderService: ContentHeaderService) {}

  ngOnInit() {
    this.isFilterActive$ = this.contentHeaderService.isFilterActive$;
    this.showFilter$ = this.contentHeaderService.showFilter$;
    this.showBreadCrumbs$ = this.contentHeaderService.showBreadcrumbs$;
    this.activeModule$ = this.contentHeaderService.module$;
  }

  toggleFilter() {
    this.contentHeaderService.toggleFilter();
  }
}
