import { BookingPlan } from '@/shared/types/booking-plan-types';
import { RadioButton } from '@/manager/shared/components/RadioButton';
import { getRadioGroupHost } from '@/manager/shared/utils/locator-utils';
import { BaseComponent } from '@/shared/base/BaseComponent';
import { BookingPlanPeriod } from '@/shared/types/booking-plan-types';

export class BookingPlanPeriodRadioGroup extends BaseComponent {
  readonly main = getRadioGroupHost(this.host);
  readonly weeklyRadioButton = new RadioButton(this.main.getByTestId('booking-plan-period-radio-group-item-weekly'));
  readonly monthlyRadioButton = new RadioButton(this.main.getByTestId('booking-plan-period-radio-group-item-monthly'));

  async fill(data: BookingPlan): Promise<void> {
    await this.check(data.period);
  }

  private check(option: BookingPlanPeriod): Promise<void> {
    switch (option) {
      case 'weekly':
        return this.weeklyRadioButton.check();
      case 'monthly':
        return this.monthlyRadioButton.check();
    }
  }
}
