import { BookingAdjustmentProrationBehavior } from '@/manager/modules/booking/booking-types';
import { RadioButton } from '@/manager/shared/components/RadioButton';
import { getFieldSetHost } from '@/manager/shared/utils/locator-utils';
import { BaseComponent } from '@/shared/base/BaseComponent';

export class BookingAdjustmentProrationRadioGroup extends BaseComponent {
  readonly main = getFieldSetHost(this.host, 'Proration behaviour');
  readonly invoiceOnDayOfAdjustmentRadioButton = new RadioButton(
    this.main.getByTestId('booking-adjust-proration-radio-group-item-immediately')
  );

  async fill(behavior: BookingAdjustmentProrationBehavior): Promise<void> {
    switch (behavior) {
      case 'immediately':
        return this.invoiceOnDayOfAdjustmentRadioButton.check();
      default:
        throw new Error(`The proration form offers no "${behavior}" option`);
    }
  }
}
