import { AbstractDialog } from '@/shared/abstractClasses/abstract-dialog';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { IBusinessActivityResponse } from '../../models';
import { ConsumerBusinessActivitiesFormComponent } from './form.component';
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';

@Component({
  selector: 'partner-consumer-businessActivities-form',
  templateUrl: './form-dialog.component.html',
  imports: [SharedDialogComponent, ConsumerBusinessActivitiesFormComponent],
})
export class ConsumerBusinessActivitiesFormDialogComponent extends AbstractDialog {
  @Output() onSubmit = new EventEmitter<IBusinessActivityResponse>();
  @Input() initialValues?: IBusinessActivityResponse;
  @Input() editMode?: boolean;

  @Input({ required: true }) consumerId!: string;
  @Input() businessActivityId!: string;

  get preparedTitle() {
    return `${this.editMode ? 'ویرایش' : 'ایجاد'} فعالیت اقتصادی`;
  }

  onFormSubmit(response: IBusinessActivityResponse) {
    this.onSubmit.emit(response);
    this.close();
  }
}
