import { BookingBasketContent } from '@/portal/modules/booking/components/BookingBasketContent';
import { BookingCustomerView } from '@/portal/modules/booking/views/BookingCustomerView';
import { BaseView } from '@/shared/base/BaseView';

export class BookingBasketView extends BaseView {
  readonly body = this.host.getByTestId('basket-content-modal');
  readonly submitButton = this.body.getByTestId('submit-button');
  readonly basketContent = new BookingBasketContent(this.body);

  add(discountCode: string): Promise<void> {
    return this.basketContent.add(discountCode);
  }

  async confirm(): Promise<BookingCustomerView> {
    await Promise.all([this.host.waitForURL('**/unit-type/*/customer?lang=en'), this.submitButton.click()]);
    return new BookingCustomerView(this.host);
  }
}
