import { Component, EventEmitter, Input, Output } from '@angular/core';
import { v4 as uuid } from 'uuid';
import { Required } from '../../decorators/required.decorator';

@Component({
  selector: 'app-radio-group',
  templateUrl: './radio-group.component.html',
  styleUrls: ['./radio-group.component.scss'],
})
export class RadioGroupComponent {
  @Input() @Required() options!: string[];
  @Input() @Required() label!: string;
  @Input() fieldName = uuid();
  @Input() selected!: string;
  @Input() direction: 'row' | 'column' = 'row';

  @Output() selectedChange = new EventEmitter<string>();

  handleChange(newValue: string) {
    this.selectedChange.emit(newValue);
  }
}
