import { RadioButton } from '@/manager/shared/components/RadioButton';
import { getRadioGroupHost } from '@/manager/shared/utils/host-utils';
import { BaseComponent } from '@/shared/base/BaseComponent';
import { IDiscountDurationOption } from '@/shared/types/discount-types';

export class DiscountDurationRadioGroup extends BaseComponent {
  readonly main = getRadioGroupHost(this.host);
  readonly onceRadioButton = new RadioButton(this.main.locator('.ui-radio-group-item').nth(0));
  readonly multipleMonthsRadioButton = new RadioButton(this.main.locator('.ui-radio-group-item').nth(1));
  readonly foreverRadioButton = new RadioButton(this.main.locator('.ui-radio-group-item').nth(2));
  readonly content = this.main.locator('.content');

  check(option: IDiscountDurationOption): Promise<void> {
    switch (option) {
      case 'once':
        return this.onceRadioButton.check();
      case 'multiple_months':
        return this.multipleMonthsRadioButton.check();
      case 'forever':
        return this.foreverRadioButton.check();
    }
  }
}
