"use client";

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

export const SitesPage = createExperienceListPage({
  title: "سایت‌ها",
  breadcrumb: "سایت‌ها",
  resourceKey: "sites",
  permission: "experience.sites.view",
  api: experienceApi.sites,
  columns: [
    { key: "code", header: "کد" },
    { key: "name", header: "نام" },
    { key: "publish_status", header: "انتشار", type: "status" },
    { key: "primary_domain", header: "دامنه اصلی" },
    { key: "created_at", header: "ایجاد", type: "datetime" },
  ],
  createFields: [
    { name: "workspace_id", label: "فضای کاری", type: "workspace", required: true, createOnly: true },
    { name: "code", label: "کد یکتا", required: true, placeholder: "main", hint: "لاتین/عدد/_/- حداقل ۲ کاراکتر (مثل: main). فارسی و فاصله مجاز نیست." },
    { name: "name", label: "نام", required: true },
    { name: "description", label: "توضیح", type: "textarea" },
    {
      name: "publish_status",
      label: "وضعیت انتشار",
      type: "select",
      options: [
        { value: "draft", label: "پیش‌نویس" },
        { value: "published", label: "منتشر" },
        { value: "archived", label: "بایگانی" },
      ],
    },
    { name: "default_locale", label: "زبان پیش‌فرض", placeholder: "fa" },
    {
      name: "default_direction",
      label: "جهت",
      type: "select",
      options: [
        { value: "rtl", label: "راست‌به‌چپ" },
        { value: "ltr", label: "چپ‌به‌راست" },
      ],
    },
    { name: "primary_domain", label: "دامنه اصلی (اختیاری)" },
  ],
  editFields: [
    { name: "name", label: "نام", required: true },
    { name: "description", label: "توضیح", type: "textarea" },
    { name: "default_locale", label: "زبان پیش‌فرض" },
    {
      name: "default_direction",
      label: "جهت",
      type: "select",
      options: [
        { value: "rtl", label: "راست‌به‌چپ" },
        { value: "ltr", label: "چپ‌به‌راست" },
      ],
    },
    { name: "primary_domain", label: "دامنه اصلی" },
    { name: "version", label: "نسخه", type: "number", required: true, editOnly: true },
  ],
});

export default SitesPage;
