import { ConsumerStore } from '@/domains/consumer/store/main.store';
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
import { Component, computed, inject, signal } from '@angular/core';
import { ConsumerProfileFormComponent } from '../components/form.component';
import { ConsumerResetPasswordCardComponent } from '../components/reset-password-card.component';

@Component({
  selector: 'consumer-profile',
  templateUrl: './single.component.html',
  imports: [
    AppCardComponent,
    KeyValueComponent,
    ConsumerResetPasswordCardComponent,
    ConsumerProfileFormComponent,
  ],
})
export class ConsumerProfileComponent {
  private readonly store = inject(ConsumerStore);

  readonly profile = computed(() => this.store.entity());
  readonly isLegal = computed(() => this.profile()?.type?.value === 'LEGAL');

  editing = signal(false);

  edit() {
    this.editing.set(true);
  }

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