import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { Breadcrumb, BreadcrumbService } from '@core/breadcrumb';
import { Config } from '@core/config';

@Component({
  selector: 'page-assortment',
  templateUrl: 'assortment.component.html',
  styleUrls: ['assortment.component.css'],
  changeDetection: ChangeDetectionStrategy.OnPush,
  standalone: false,
})
export class AssortmentComponent implements OnInit {
  get breadcrumbKey(): string {
    return this._config.get('process.ids.assortment');
  }

  constructor(
    private _config: Config,
    private _breadcrumb: BreadcrumbService,
  ) {}

  ngOnInit() {
    this.createBreadcrumbIfNotExists();
  }

  async createBreadcrumbIfNotExists(): Promise<void> {
    const crumb: Breadcrumb = {
      key: this.breadcrumbKey,
      name: 'Sortiment',
      path: '/filiale/assortment',
      section: 'branch',
      tags: ['main'],
    };

    await this._breadcrumb.addBreadcrumbIfNotExists(crumb);
  }
}
