import { Component, Input, Output, EventEmitter } from '@angular/core';
import { DynamicField } from '../chart-config-manager.component';

@Component({
  selector: 'app-dynamic-field-form',
  templateUrl: './dynamic-field-form.component.html',
  styleUrls: ['./dynamic-field-form.component.scss']
})
export class DynamicFieldFormComponent {
  @Input() dynamicField: Partial<DynamicField> = {};
  @Input() isEdit = false;
  @Output() save = new EventEmitter<Partial<DynamicField>>();
  @Output() cancel = new EventEmitter<void>();

  fieldTypes = [
    'text',
    'number',
    'email',
    'password',
    'date',
    'select',
    'checkbox',
    'radio',
    'textarea'
  ];

  onSubmit(): void {
    this.save.emit(this.dynamicField);
  }

  onCancel(): void {
    this.cancel.emit();
  }
}