import { Component, Input, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Observable } from 'rxjs';
import { KeyValue } from '../../models/key-value';
import { FilterService } from '../../services/filters.service';

@Component({
  selector: 'fbi-select',
  standalone: true,
  imports: [CommonModule],
  templateUrl: './select.component.html',
  styleUrl: './select.component.scss',
})
export class SelectComponent {
  @Input() label!: string;
  @Input() key!: string;
  @Input() data!: Observable<KeyValue[]>;

  private filterService = inject(FilterService);

  onChange(event: any): void {
    this.filterService.set(this.key, event?.target?.value);
  }
}
