import type { Page, Locator } from '@playwright/test';

export class AdminDashboard {
  readonly page: Page;
  readonly tabStats: Locator;
  readonly tabConfig: Locator;
  readonly tabExport: Locator;
  readonly tabUsers: Locator;
  readonly userCount: Locator;
  readonly uploadCount: Locator;
  readonly imageSizeInput: Locator;
  readonly videoSizeInput: Locator;
  readonly privacyNoteTextarea: Locator;
  readonly saveConfigButton: Locator;

  constructor(page: Page) {
    this.page = page;
    this.tabStats = page.getByRole('button', { name: /stats/i });
    this.tabConfig = page.getByRole('button', { name: /config/i });
    this.tabExport = page.getByRole('button', { name: /^export$/i });
    this.tabUsers = page.getByRole('button', { name: /nutzer/i });
    this.userCount = page.locator('[data-testid="stat-user-count"]');
    this.uploadCount = page.locator('[data-testid="stat-upload-count"]');
    this.imageSizeInput = page.locator('input[name="max_image_size_mb"]');
    this.videoSizeInput = page.locator('input[name="max_video_size_mb"]');
    this.privacyNoteTextarea = page.locator('textarea[name="privacy_note"]');
    this.saveConfigButton = page.getByRole('button', { name: /speichern/i }).first();
  }

  async goto() {
    await this.page.goto('/admin');
  }
}
