import { PageLoadingComponent } from '@/shared/components/page-loading.component';
import { Component, computed, inject, signal } from '@angular/core';
import { ActivatedRoute, RouterOutlet } from '@angular/router';
import { ConsumerSaleInvoiceStore } from '../store/main.store';

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

  readonly invoiceId = signal<string>(this.route.snapshot.paramMap.get('invoiceId')!);

  readonly loading = computed(() => this.store.loading());

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

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