import { InvoiceIssueCreditNoteOption } from '@/manager/modules/invoice/invoice-types';
import { RadioButton } from '@/manager/shared/components/RadioButton';
import { getRadioGroupHost } from '@/manager/shared/utils/locator-utils';
import { BaseComponent } from '@/shared/base/BaseComponent';

export class InvoiceIssueCreditNoteRadioGroup extends BaseComponent {
  readonly main = getRadioGroupHost(this.host);
  readonly refundToPaymentMethodRadioButton = new RadioButton(
    this.main.getByTestId('invoice-issue-credit-note-radio-group-item-refund_to_payment_method')
  );
  readonly refundToCustomerBalanceRadioButton = new RadioButton(
    this.main.getByTestId('invoice-issue-credit-note-radio-group-item-credit_customer_balance')
  );
  readonly creditOutsideOfStripeRadioButton = new RadioButton(
    this.main.getByTestId('invoice-issue-credit-note-radio-group-item-credit_outside_stripe')
  );

  check(option: InvoiceIssueCreditNoteOption): Promise<void> {
    switch (option) {
      case 'refund to payment method':
        return this.refundToPaymentMethodRadioButton.check();
      case 'refund to customer balance':
        return this.refundToCustomerBalanceRadioButton.check();
      case 'credit outside of stripe':
        return this.creditOutsideOfStripeRadioButton.check();
    }
  }
}
