// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
import { BreadcrumbService } from '@/core/services';
import pageParamsUtils from '@/utils/page-params.utils';
import { Component, computed, inject, signal } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ConsumerComplexesComponent } from '../../components/complexes/list.component';
import { partnerConsumerComplexesNamedRoutes } from '../../constants/routes/complexes';
import { BusinessActivityStore } from '../../store/businessActivity.store';
import { ConsumerStore } from '../../store/consumer.store';

@Component({
  selector: 'partner-user-complexes',
  templateUrl: './list.component.html',
  imports: [ConsumerComplexesComponent],
})
export class PartnerUserComplexesComponent {
  private readonly route = inject(ActivatedRoute);
  private readonly breadcrumbService = inject(BreadcrumbService);
  private readonly consumerStore = inject(ConsumerStore);
  private readonly businessStore = inject(BusinessActivityStore);

  pageParams = computed(() => pageParamsUtils(this.route));
  consumerId = signal<string>(this.pageParams()['consumerId']);
  businessId = signal<string>(this.pageParams()['businessActivityId']);

  ngAfterViewInit() {
    this.setBreadcrumb();
  }

  setBreadcrumb() {
    this.breadcrumbService.setItems([
      ...this.consumerStore.breadcrumbItems(),
      ...this.businessStore.breadcrumbItems(),
      {
        title: partnerConsumerComplexesNamedRoutes.complexes.meta.title,
        routerLink: partnerConsumerComplexesNamedRoutes.complexes.meta.pagePath!(
          this.consumerId(),
          this.businessId(),
        ),
      },
    ]);
  }
}
