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

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

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

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

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

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