import { AbstractForm } from '@/shared/abstractClasses';
import { AppCheckboxComponent } from '@/shared/components/checkbox/checkbox.component';
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
import { Component, inject } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { IPosConfigPrintRequestPayload, IPosConfigPrintResponse } from './models';
import { PosConfigPrintService } from './services/main.service';

@Component({
  selector: 'pos-config-print-form',
  templateUrl: 'form.component.html',
  imports: [ReactiveFormsModule, AppCheckboxComponent, FormFooterActionsComponent],
})
export class PosConfigPrintFormComponent extends AbstractForm<
  IPosConfigPrintRequestPayload,
  IPosConfigPrintResponse
> {
  private readonly service = inject(PosConfigPrintService);

  initForm = () => {
    const form = this.fb.group({
      business_name: [true, []],
      complex_name: [false],
      pos_name: [false],
      invoice_template: [false],
      fiscal_id: [false],
      economic_code: [false],
      customer_name: [false],
      customer_mobile: [false],
      customer_national_id: [false],
      customer_postal_code: [false],
      customer_economic_code: [false],
      payment_type: [false],
      show_payment_info: [false],
      show_items: [false],
    });

    return form;
  };

  form = this.initForm();

  submitForm() {
    const formValue = this.form.value as IPosConfigPrintRequestPayload;
    return this.service.submit(formValue);
  }
}
