import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Router } from '@angular/router';
import { AdminCustomersFacade } from '../facade/admin-customers.facade';
import { TranslatePipe } from '../../../../i18n/translate.pipe';
import { LanguageService } from '../../../../services/language.service';
import { ButtonComponent } from '../../../../shared/ui/button/button.component';
import { InputComponent } from '../../../../shared/ui/input/input.component';
import { BadgeComponent } from '../../../../shared/ui/badge/badge.component';
import { TableComponent } from '../../../../shared/ui/table/table.component';
import { EmptyStateComponent } from '../../../../shared/ui/empty-state/empty-state.component';
import { SkeletonComponent } from '../../../../shared/ui/skeleton/skeleton.component';

@Component({
  selector: 'app-admin-customers-list-page',
  standalone: true,
  imports: [CommonModule, FormsModule, TranslatePipe, ButtonComponent, InputComponent, BadgeComponent, TableComponent, EmptyStateComponent, SkeletonComponent],
  templateUrl: './admin-customers-list-page.component.html',
  styleUrls: ['./admin-customers-list-page.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class AdminCustomersListPageComponent {
  readonly facade = inject(AdminCustomersFacade);
  private readonly router = inject(Router);
  private readonly languageService = inject(LanguageService);

  constructor() {
    this.facade.loadList();
  }

  view(email: string): void {
    void this.router.navigate([this.languageService.currentLanguage(), 'backoffice', 'customers', encodeURIComponent(email)]);
  }
}
