import { DatePicker } from '@/portal/shared/components/DatePicker';
import { BaseComponent } from '@/shared/base/BaseComponent';
import { formatDate } from '@/shared/utils/formatters';

export class BookingMoveInDateSection extends BaseComponent {
  private readonly moveInDatePicker = new DatePicker(this.host.getByTestId('date-picker'));
  private readonly nextSectionButton = this.host.getByTestId('next-section-button');

  async select(moveInDate: Date): Promise<void> {
    if (formatDate(moveInDate) !== formatDate(new Date())) {
      await this.moveInDatePicker.select(moveInDate);
    }

    await this.nextSectionButton.click();
  }
}
