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

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

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

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

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

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