import { PageLoadingComponent } from '@/shared/components/page-loading.component';
import { Component, computed, inject, signal } from '@angular/core';
import { ActivatedRoute, RouterOutlet } from '@angular/router';
import { ConsumerCustomerStore } from '../store/customer.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(ConsumerCustomerStore);

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

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

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

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