// import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
import { IPaginatedResponse } from '@/core/models/service.model';
import { AbstractList } from '@/shared/abstractClasses/abstract-list';
import {
  IColumn,
  PageDataListComponent,
} from '@/shared/components/pageDataList/page-data-list.component';
import { Component, inject } from '@angular/core';
import { Router } from '@angular/router';
import { Observable } from 'rxjs';
import { GuildFormComponent } from '../components/form.component';
import { guildsNamedRoutes } from '../constants';
import { IGuildResponse } from '../models';
import { GuildsService } from '../services/main.service';

@Component({
  selector: 'admin-guilds',
  templateUrl: './list.component.html',
  imports: [PageDataListComponent, GuildFormComponent],
})
export class GuildsComponent extends AbstractList<IGuildResponse> {
  private readonly service = inject(GuildsService);
  private readonly router = inject(Router);

  override setColumns(): void {
    this.columns = [
      { field: 'name', header: 'عنوان' },
      { field: 'code', header: 'کد' },
      { field: 'businessActivitiesCount', header: 'تعداد فعالیت‌‌های اقتصادی‌ مرتبط' },
      {
        field: 'created_at',
        header: 'تاریخ ایجاد',
        type: 'date',
      },
    ] as IColumn[];
  }

  override getDataRequest(): void | Observable<IPaginatedResponse<IGuildResponse>> {
    return this.service.getAll();
  }

  toSinglePage(guild: IGuildResponse) {
    this.router.navigateByUrl(guildsNamedRoutes.guild.meta.pagePath!(guild.id));
  }
}
