import { Component, Input, OnInit } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import {
  IonButton,
  IonButtons,
  IonContent,
  IonHeader,
  IonInput,
  IonItem,
  IonTitle,
  IonToolbar,
  ModalController,
} from '@ionic/angular/standalone';
export interface AgentUserInputField {
  name: string; // 字段名称
  type: string; // 输入类型
  placeholder: string; // 字段说明
}

@Component({
  selector: 'app-agent-userinput',
  templateUrl: './agent-userinput.component.html',
  styleUrls: ['./agent-userinput.component.scss'],
  standalone: true,
  imports: [
    IonHeader,
    IonToolbar,
    IonTitle,
    IonButton,
    IonButtons,
    IonItem,
    IonInput,
    IonContent,
    FormsModule,
    ReactiveFormsModule,
  ],
})
export class AgentUserinputComponent implements OnInit {
  ngOnInit() {}

  @Input()
  fieldsArray: AgentUserInputField[] = [];
  @Input()
  userInputData: any = {};

  constructor(private modalCtrl: ModalController) {}

  cancel() {
    return this.modalCtrl.dismiss(null, 'cancel');
  }

  confirm() {
    return this.modalCtrl.dismiss(this.userInputData, 'confirm');
  }
}
