import { AbstractDialog } from '@/shared/abstractClasses/abstract-dialog';
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { IBusinessActivityResponse } from '../../models';
import { ConsumerBusinessActivitiesFormComponent } from './form.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();
  }
}
