import { Component, EventEmitter, Input, Output } from '@angular/core';
import { NonNullableFormBuilder } from '@angular/forms';
import { CommonNzModule } from '../../../../common.nz.module';
import { SettingService } from '../../../../services/setting.service';

@Component({
  selector: 'user-action',
  standalone: true,
  imports: [CommonNzModule],
  templateUrl: './user-action.component.html',
  styleUrl: './user-action.component.less',
})
export class UserActionComponent {
  @Input() roleOptions: Option<string>[] = [];
  @Input() companyOptions: Option<string>[] = [];
  @Input() statusOptions: Option<number>[] = [];
  @Input() batchButtonVisible = false;

  @Output() onSearch = new EventEmitter();
  @Output() onReset = new EventEmitter();
  @Output() handleAdd = new EventEmitter();
  @Output() handleBatchDelete = new EventEmitter();
  @Output() handleImport = new EventEmitter();

  constructor(
    private fb: NonNullableFormBuilder,
    private setting: SettingService
  ) {}
  validateForm = this.fb.group({
    company: this.fb.control<string | null>(null),
    empno: this.fb.control<string | null>(null),
    name: this.fb.control<string | null>(null),
    role: this.fb.control<string | null>(null),
    status: this.fb.control<number>(0),
  });
  inputFields = [
    { label: '工号', key: 'empno' },
    { label: '姓名', key: 'name' },
  ];

  handleSearch() {
    this.onSearch.emit();
  }
  handleReset() {
    this.validateForm.reset();
    this.onReset.emit();
  }
  onAdd() {
    this.handleAdd.emit();
  }
  onBatchDelete() {
    this.handleBatchDelete.emit();
  }
  onImport() {
    this.handleImport.emit();
  }
  get isSchoolAdmin() {
    // return this.setting.isSchoolAdmin;
    return false;
  }
}
