import { IPaginatedResponse } from '@/core/models/service.model';
import { AbstractSelectComponent } from '@/shared/abstractClasses';
import { UikitFieldComponent } from '@/uikit';
import { Component, inject, Input } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { Select } from 'primeng/select';
import { IGoodCategoriesResponse } from '../../models';
import { GuildGoodCategoriesService } from '../../services/goodCategories.service';

@Component({
  selector: 'admin-guild-categories-select',
  templateUrl: './select.component.html',
  imports: [UikitFieldComponent, Select, ReactiveFormsModule],
})
export class GuildCategoriesSelectComponent extends AbstractSelectComponent<
  IGoodCategoriesResponse,
  IPaginatedResponse<IGoodCategoriesResponse>
> {
  @Input() override showClear: boolean = false;
  @Input() label: string = '';
  @Input() guildId!: string;
  private readonly service = inject(GuildGoodCategoriesService);

  ngOnChanges() {
    if (this.guildId) {
      this.getData();
    }
  }

  getDataService() {
    return this.service.getAll(this.guildId);
  }
}
