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

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

  @Input() consumerId?: string;

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

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