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

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

  async goto() {
    await this.page.goto("/product/category/create");
  }

  get codeInput() {
    return this.page.getByLabel("Code");
  }

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

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

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