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 { BusinessActivityStore } from '../../store/businessActivity.store';

@Component({
  selector: 'partner-user-businessActivity-layout',
  templateUrl: './layout.component.html',
  imports: [PageLoadingComponent, RouterOutlet],
})
export class PartnerUserBusinessActivityLayoutComponent {
  private readonly store = inject(BusinessActivityStore);
  private readonly route = inject(ActivatedRoute);

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

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

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

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