import { PageLoadingComponent } from '@/shared/components/page-loading.component';
import pageParamsUtils from '@/utils/page-params.utils';
import { Component, computed, inject } from '@angular/core';
import { ActivatedRoute, RouterOutlet } from '@angular/router';
import { ConsumerComplexStore } from '../../store/complex.store';

@Component({
  selector: 'consumer-complex-layout',
  templateUrl: './layout.component.html',
  imports: [PageLoadingComponent, RouterOutlet],
})
export class ConsumerComplexLayoutComponent {
  private readonly store = inject(ConsumerComplexStore);
  private readonly route = inject(ActivatedRoute);

  readonly loading = computed(() => this.store.loading());
  readonly pageParams = computed(() => pageParamsUtils(this.route));

  readonly businessId = computed(() => this.pageParams()['businessActivityId']!);
  readonly complexId = computed(() => this.pageParams()['complexId']!);

  getData() {
    this.store.getData(this.businessId(), this.complexId());
  }

  ngOnInit() {
    this.getData();
  }
}
