import { communicationApi } from "@/modules/communication/services/communication-api"; import type { CommunicationListConfig } from "@/modules/communication/components/CommunicationListCrudPage"; export const communicationResources = { providers: { title: "ارائه‌دهندگان SMS", description: "پیکربندی mock، Payamak و failover", resourceKey: "providers", permission: "communication.providers.view", api: { list: (tenantId: string) => communicationApi.providers.list(tenantId), create: (tenantId: string, body: Record) => communicationApi.providers.create(tenantId, body), update: (tenantId: string, id: string, body: Record) => communicationApi.providers.update(tenantId, id, body), remove: (tenantId: string, id: string) => communicationApi.providers.remove(tenantId, id), }, columns: [ { key: "name", header: "نام" }, { key: "provider_kind", header: "نوع" }, { key: "channel", header: "کانال" }, { key: "status", header: "وضعیت", type: "status" as const }, { key: "priority", header: "اولویت" }, { key: "circuit_state", header: "Circuit" }, ], createFields: [ { name: "name", label: "نام", required: true }, { name: "provider_kind", label: "نوع", type: "select" as const, required: true, options: [ { value: "mock", label: "Mock" }, { value: "payamak", label: "Payamak" }, ], }, { name: "channel", label: "کانال", required: true, placeholder: "sms" }, { name: "priority", label: "اولویت", type: "number" as const }, { name: "rate_limit_per_minute", label: "Rate limit/min", type: "number" as const }, ], } satisfies CommunicationListConfig, senders: { title: "Sender ID", description: "شماره‌های ارسال SMS", resourceKey: "senders", permission: "communication.senders.view", api: { list: (tenantId: string) => communicationApi.providers.senders.list(tenantId), create: (tenantId: string, body: Record) => communicationApi.providers.senders.create(tenantId, body), }, columns: [ { key: "value", header: "شماره / شناسه" }, { key: "label", header: "برچسب" }, { key: "channel", header: "کانال" }, { key: "is_default", header: "پیش‌فرض" }, { key: "is_active", header: "فعال" }, ], createFields: [ { name: "channel", label: "کانال", required: true, placeholder: "sms" }, { name: "value", label: "مقدار", required: true }, { name: "label", label: "برچسب" }, ], readOnly: false, } satisfies CommunicationListConfig, templates: { title: "قالب‌های پیام", resourceKey: "templates", permission: "communication.templates.view", api: { list: (tenantId: string) => communicationApi.templates.list(tenantId), create: (tenantId: string, body: Record) => communicationApi.templates.create(tenantId, body), }, columns: [ { key: "template_key", header: "کلید" }, { key: "name", header: "نام" }, { key: "channel", header: "کانال" }, { key: "locale", header: "زبان" }, { key: "status", header: "وضعیت", type: "status" as const }, { key: "version", header: "نسخه" }, ], createFields: [ { name: "template_key", label: "کلید قالب", required: true }, { name: "name", label: "نام", required: true }, { name: "channel", label: "کانال", required: true, placeholder: "sms" }, { name: "locale", label: "زبان", placeholder: "fa" }, { name: "body", label: "متن", type: "textarea" as const, required: true }, ], } satisfies CommunicationListConfig, recipients: { title: "گیرندگان", resourceKey: "recipients", permission: "communication.contacts.view", api: { list: (tenantId: string) => communicationApi.contacts.manual.list(tenantId), create: (tenantId: string, body: Record) => communicationApi.contacts.manual.create(tenantId, body), }, columns: [ { key: "display_name", header: "نام" }, { key: "phone", header: "موبایل" }, { key: "email", header: "ایمیل" }, { key: "created_at", header: "ایجاد", type: "datetime" as const }, ], createFields: [ { name: "display_name", label: "نام نمایشی" }, { name: "phone", label: "موبایل", required: true }, { name: "email", label: "ایمیل", type: "email" as const }, ], } satisfies CommunicationListConfig, contactSources: { title: "منابع پویای مخاطب", resourceKey: "contactSources", permission: "communication.sources.view", api: { list: (tenantId: string) => communicationApi.contacts.sources.list(tenantId), create: (tenantId: string, body: Record) => communicationApi.contacts.sources.create(tenantId, body), }, columns: [ { key: "name", header: "نام" }, { key: "source_type", header: "نوع" }, { key: "base_url", header: "URL پایه" }, { key: "is_active", header: "فعال" }, ], createFields: [ { name: "name", label: "نام", required: true }, { name: "source_type", label: "نوع منبع", type: "select" as const, required: true, options: [ { value: "crm", label: "CRM" }, { value: "loyalty", label: "Loyalty" }, { value: "sports", label: "Sports" }, { value: "restaurant", label: "Restaurant" }, { value: "external_rest", label: "REST خارجی" }, ], }, { name: "base_url", label: "URL پایه" }, { name: "endpoint_path", label: "مسیر endpoint" }, ], } satisfies CommunicationListConfig, };