"use client";

import { createHospitalityListPage } from "@/modules/hospitality/components/HospitalityListCrudPage";
import { hospitalityApi } from "@/modules/hospitality/services/hospitality-api";
import { venueFormatLabels } from "@/modules/hospitality/design-system/tokens";

export const BranchesPage = createHospitalityListPage({
  title: "مکان‌ها (Venues)",
  description: "مدیریت مکان‌های مهمان‌نوازی — کافه، رستوران، فست‌فود و …",
  breadcrumb: "مکان‌ها",
  resourceKey: "venues",
  bundleFeature: null,
  permission: "hospitality.venues.view",
  api: hospitalityApi.venues,
  columns: [
    { key: "code", header: "کد" },
    { key: "name", header: "نام" },
    {
      key: "venue_format",
      header: "نوع",
      render: (r) => venueFormatLabels[String(r.venue_format)] ?? String(r.venue_format),
    },
    { key: "status", header: "وضعیت", type: "status" },
    { key: "currency_code", header: "ارز" },
  ],
  createFields: [
    { name: "code", label: "کد", required: true },
    { name: "name", label: "نام", required: true },
    {
      name: "venue_format",
      label: "نوع کسب‌وکار",
      type: "select",
      required: true,
      options: Object.entries(venueFormatLabels).map(([value, label]) => ({ value, label })),
    },
  ],
  editFields: [
    { name: "name", label: "نام", required: true },
    {
      name: "status",
      label: "وضعیت",
      type: "select",
      options: [
        { value: "draft", label: "پیش‌نویس" },
        { value: "active", label: "فعال" },
        { value: "inactive", label: "غیرفعال" },
      ],
    },
  ],
  filterDeleted: true,
});

export default BranchesPage;
