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

export class DiscountCreateDurationRadioGroup extends BaseComponent {
  readonly main = getRadioGroupHost(this.host);
  readonly onceRadioButton = new RadioButton(this.main.getByTestId('discount-create-radio-group-item-once'));
  readonly multipleMonthsRadioButton = new RadioButton(
    this.main.getByTestId('discount-create-radio-group-item-multiple-months')
  );
  readonly foreverRadioButton = new RadioButton(this.main.getByTestId('discount-create-radio-group-item-forever'));
  readonly content = this.main.locator('.content');

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