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

export class DiscountTypeRadioGroup extends BaseComponent {
  readonly main = getRadioGroupHost(this.host);
  readonly percentageRadioButton = new RadioButton(this.main.locator('.ui-radio-group-item').nth(0));
  readonly fixedRadioButton = new RadioButton(this.main.locator('.ui-radio-group-item').nth(1));
  readonly content = this.main.locator('.content');

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