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

export class DiscountCreateTypeRadioGroup extends BaseComponent {
  readonly main = getRadioGroupHost(this.host);
  readonly percentageRadioButton = new RadioButton(
    this.main.getByTestId('discount-create-radio-group-item-percentage')
  );
  readonly fixedRadioButton = new RadioButton(this.main.getByTestId('discount-create-radio-group-item-fixed'));
  readonly content = this.main.locator('.content');

  check(type: DiscountType): Promise<void> {
    switch (type) {
      case 'percentage':
        return this.percentageRadioButton.check();
      case 'fixed':
        return this.fixedRadioButton.check();
    }
  }
}
