import { BaseDialog } from '@/manager/shared/base/BaseDialog';
import { BacsPaymentMethodAddForm } from '@/manager/modules/ui/payment-method/components/BacsPaymentMethodAddForm';
import { BacsPayment } from '@/shared/modules/payment-method/payment-method-types';
import { Page } from '@playwright/test';

export class StripeEmbeddedCheckoutAddDialog extends BaseDialog {
  readonly bacsForm = new BacsPaymentMethodAddForm(this.main);

  constructor(host: Page) {
    super(host, 'add-stripe-embedded-checkout-dialog');
  }

  async add(paymentMethod: BacsPayment): Promise<void> {
    await this.fill(paymentMethod);
    await this.submit();
  }

  async fill(paymentMethod: BacsPayment): Promise<void> {
    await this.bacsForm.fill(paymentMethod);
  }

  async submit(): Promise<void> {
    await this.bacsForm.submitButton.click();
    await this.bacsForm.submitButton.click();
  }
}
