"use client";

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

export const TemplatesPage = createExperienceListPage({
  title: "قالب‌ها",
  breadcrumb: "قالب‌ها",
  resourceKey: "templates",
  permission: "experience.templates.view",
  api: experienceApi.templates,
  columns: [
    { key: "code", header: "کد" },
    { key: "name", header: "نام" },
    { key: "page_type", header: "نوع صفحه" },
    { key: "status", header: "وضعیت", type: "status" },
    { key: "created_at", header: "ایجاد", type: "datetime" },
  ],
  createFields: [
    { name: "workspace_id", label: "فضای کاری", type: "workspace", required: true, createOnly: true },
    { name: "code", label: "کد", required: true },
    { name: "name", label: "نام", required: true },
    { name: "description", label: "توضیح", type: "textarea" },
    {
      name: "page_type",
      label: "نوع صفحه",
      type: "select",
      required: true,
      options: [
        { value: "landing", label: "لندینگ" },
        { value: "business_website", label: "وب‌سایت" },
        { value: "form", label: "فرم" },
        { value: "custom", label: "سفارشی" },
      ],
    },
    {
      name: "status",
      label: "وضعیت",
      type: "select",
      options: [
        { value: "draft", label: "پیش‌نویس" },
        { value: "active", label: "فعال" },
        { value: "archived", label: "بایگانی" },
      ],
    },
    { name: "category", label: "دسته" },
  ],
});

export default TemplatesPage;
