import { ManualPayment } from '@/manager/modules/ui/payment-method/payment-method-types';
import { MultiAutocomplete } from '@/manager/shared/components/MultiAutocomplete';
import { NumberField } from '@/manager/shared/components/NumberField';
import { getInputHostByLabel } from '@/manager/shared/utils/locator-utils';
import { BaseComponent } from '@/shared/base/BaseComponent';

export class ManualPaymentMethodAddForm extends BaseComponent {
  readonly daysUntilDueNumberField = new NumberField(getInputHostByLabel(this.host, 'Invoice due in'));
  readonly availablePaymentMethodsAutocomplete = new MultiAutocomplete(
    getInputHostByLabel(this.host, 'Payment methods')
  );

  async fill(data: ManualPayment): Promise<void> {
    await this.daysUntilDueNumberField.fill(data.daysUntilDue);
    await this.availablePaymentMethodsAutocomplete.fill(data.availablePaymentMethods);
  }
}
