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

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

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

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

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