import { CookieConsentData } from '@/portal/modules/ui/cookie-consent/cookie-consent-types';
import { Checkbox } from '@/portal/shared/components/Checkbox';
import { BaseView } from '@/shared/base/BaseView';

export class CookieConsentView extends BaseView {
  readonly body = this.host.getByTestId('cookie-consent-modal');
  readonly saveSelectedSettingsButton = this.body.locator('button[type="button"]');
  readonly acceptAllButton = this.body.locator('button[type="submit"]');
  readonly marketingCookieCheckbox = new Checkbox(this.body.getByTestId('marketing-cookie-switch'));

  async selectSettings(data: CookieConsentData): Promise<void> {
    if (data.allowMarketing) {
      await this.marketingCookieCheckbox.check();
    }

    return this.saveSelectedSettingsButton.click();
  }

  acceptAll(): Promise<void> {
    return this.acceptAllButton.click();
  }
}
