import { Component, EventEmitter, Input, Output } from "@angular/core";
import { MasterService } from "../../service/master-api.service";
interface Icon {
  name: string;
  icon: string;
}
@Component({
  selector: "app-select-icon",
  templateUrl: "./select-icon.component.html",
  styleUrls: ["./select-icon.component.css"],
})
export class SelectIconComponent {
  // @Output() iconSelected: EventEmitter<string> = new EventEmitter<string>();
  @Output() iconSelected = new EventEmitter<string>();
  @Input() selectedIcon: string;
  icons: any[] = [];
  constructor(private masterService: MasterService) {}
  ngOnInit(): void {
    this.masterService.getIconData().subscribe((res) => {
      this.icons = res.rows;
    });
  }

  onSelect(icon: Icon): void {
    console.log(icon);
    if (icon) {
      this.iconSelected.emit(icon.icon);
    } else {
      this.iconSelected.emit(undefined);
    }
    
  }
}
