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

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

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

  readonly posId = computed(() => this.pageParams()['posId']!);

  getData() {
    this.store.getData(this.posId());
  }

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