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

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

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

  get preparedTitle() {
    return `${this.editMode ? 'ویرایش' : 'افزودن'} شعبه`;
  }

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