import { BaseDialog } from '@/manager/shared/base/BaseDialog';
import { SingleDatePicker } from '@/manager/shared/components/SingleDatePicker';
import { getSnackbarHost } from '@/manager/shared/utils/locator-utils';
import { Page } from '@playwright/test';

export class BookingAdjustMoveInDateDialog extends BaseDialog {
  readonly moveInDatePicker = new SingleDatePicker(this.main.getByTestId('date-picker'));
  readonly snackbar = getSnackbarHost(this.host, 'Move-in date updated successfully');

  constructor(host: Page) {
    super(host, 'booking-adjust-move-in-date-dialog');
  }

  async edit(moveInDate: Date): Promise<void> {
    await this.moveInDatePicker.fill(moveInDate);
    await Promise.all([this.snackbar.waitFor(), this.submitButton.click()]);
  }
}
