import { SharedSaleInvoiceSingleViewComponent } from '@/shared/components/invoices/sale-invoice-single-view.component';
import pageParamsUtils from '@/utils/page-params.utils';
import { Component, computed, inject, signal } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { PublicSaleInvoiceStore } from '../store/main.store';

@Component({
  selector: 'public-saleInvoice',
  templateUrl: './single.component.html',
  imports: [SharedSaleInvoiceSingleViewComponent],
})
export class PublicSaleInvoiceComponent {
  private readonly route = inject(ActivatedRoute);
  private readonly store = inject(PublicSaleInvoiceStore);

  pageParams = computed(() => pageParamsUtils(this.route));
  invoiceId = signal<string>(this.pageParams()['invoiceId']);

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

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