import type { Page } from "@playwright/test";

export class CategoryEditFormPage {
  private page: Page;
  constructor(page: Page) {
    this.page = page;
  }

  async goto(id: string) {
    await this.page.goto(`/product/category/${id}/edit`);
  }

  get nameInput() {
    return this.page.getByLabel("Name");
  }

  get submitButton() {
    return this.page.getByRole("button", { name: /save|update/i });
  }

  async fill(fields: { name?: string }) {
    if (fields.name) await this.nameInput.fill(fields.name);
  }
}
