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

export class AddPaymentMethodRadioGroup 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: IPaymentMethod): 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;
    }
  }
}
