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

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

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

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

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

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