import { AbstractFormDialog } from '@/shared/abstractClasses';
import { InputComponent } from '@/shared/components';
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
import { Component, inject } from '@angular/core';
import { ReactiveFormsModule, Validators } from '@angular/forms';
import { ILicenseRequest, ILicenseResponse } from '../models';
import { LicensesService } from '../services/main.service';
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';

@Component({
  selector: 'license-form',
  templateUrl: './form.component.html',
  imports: [ReactiveFormsModule, SharedDialogComponent, InputComponent, FormFooterActionsComponent],
})
export class LicenseFormComponent extends AbstractFormDialog<ILicenseRequest, ILicenseResponse> {
  private service = inject(LicensesService);

  form = this.fb.group({
    name: ['', [Validators.required]],
  });

  override submitForm(payload: ILicenseRequest) {
    return this.service.create(payload);
  }
}
