import { ICookieConsentData } from '@/apps/portal/modules/ui/cookie-consent/types/cookie-consent-types';
import { Checkbox } from '@/apps/portal/shared/components/inputs/Checkbox';
import { BaseView } from '@/shared/modules/base/views/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: ICookieConsentData): Promise<void> {
    data.allowMarketing && (await this.marketingCookieCheckbox.check());
    return this.saveSelectedSettingsButton.click();
  }

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