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

export class PaymentMethodAddRadioGroup extends BaseComponent {
  readonly main = getRadioGroupHost(this.host);
  readonly cardRadioButton = new RadioButton(this.main.locator('.ui-radio-group-item', { hasText: 'Card' }));
  readonly sepaRadioButton = new RadioButton(this.main.locator('.ui-radio-group-item', { hasText: 'SEPA' }));
  readonly bacsDebitRadioButton = new RadioButton(this.main.locator('.ui-radio-group-item', { hasText: 'Bacs Debit' }));

  async check(option: PaymentMethod): Promise<void> {
    switch (option.kind) {
      case 'card':
        await this.cardRadioButton.check();
        break;
      case 'sepa':
        await this.sepaRadioButton.check();
        break;
      case 'bacs':
        await this.bacsDebitRadioButton.check();
        break;
    }
  }
}
