import { BookingUnitTypeList } from '@/apps/portal/modules/booking/components/BookingUnitTypeList';
import { BookingOptionsView } from '@/apps/portal/modules/booking/views/BookingOptionsView';
import { BookingUnitTypeView } from '@/apps/portal/modules/booking/views/BookingUnitTypeView';
import { BaseView } from '@/shared/modules/base/views/BaseView';

export class BookingSizeNotAvailableView extends BaseView {
  readonly unitTypeList = new BookingUnitTypeList(this.host.getByTestId('unit-type-list'));
  readonly backToSizeSelectionButton = this.host.getByTestId('back-to-size-selection-button');

  async select(unitType: string): Promise<BookingOptionsView> {
    await Promise.all([
      this.host.waitForURL('**/unit-type/*/options?section=billingPeriod&lang=en'),
      this.unitTypeList.select(unitType),
    ]);
    return new BookingOptionsView(this.host);
  }

  async goBackToSizeSelection(): Promise<BookingUnitTypeView> {
    await this.backToSizeSelectionButton.click();
    return new BookingUnitTypeView(this.host);
  }
}
