"use client";

import { createExperienceListPage } from "@/modules/experience/components/ExperienceListCrudPage";
import { experienceApi } from "@/modules/experience/services/experience-api";

export const FormsPage = createExperienceListPage({
  title: "فرم‌ها",
  breadcrumb: "فرم‌ها",
  resourceKey: "forms",
  permission: "experience.forms.view",
  api: experienceApi.forms,
  columns: [
    { key: "code", header: "کد" },
    { key: "name", header: "نام" },
    { key: "status", header: "وضعیت", type: "status" },
    { key: "created_at", header: "ایجاد", type: "datetime" },
  ],
  createFields: [
    { name: "workspace_id", label: "فضای کاری", type: "workspace", required: true, createOnly: true },
    { name: "site_id", label: "سایت (اختیاری)", type: "site" },
    { name: "code", label: "کد", required: true },
    { name: "name", label: "نام", required: true },
    { name: "description", label: "توضیح", type: "textarea" },
    {
      name: "status",
      label: "وضعیت",
      type: "select",
      options: [
        { value: "draft", label: "پیش‌نویس" },
        { value: "active", label: "فعال" },
        { value: "archived", label: "بایگانی" },
      ],
    },
  ],
  detailHref: (row) => (row.id ? `/experience/forms/${row.id}/builder` : null),
});

export default FormsPage;
