115 lines
3.9 KiB
TypeScript
115 lines
3.9 KiB
TypeScript
export const PLUGIN_STORE_DURATIONS = [30, 90, 180, 360] as const;
|
|||
|
|
|
||
|
|
export type PluginStoreDuration = (typeof PLUGIN_STORE_DURATIONS)[number];
|
||
|
|
|
||
|
|
export const PLUGIN_CATALOG_SEED: Array<{
|
||
|
|
settingKey: string;
|
||
|
|
titleFa: string;
|
||
|
|
description: string;
|
||
|
|
}> = [
|
||
|
|
{
|
||
|
|
settingKey: 'jibit_enabled',
|
||
|
|
titleFa: 'احراز هویت جیبیت',
|
||
|
|
description:
|
||
|
|
'سرویس جیبیت برای تطبیق کد ملی، موبایل و کارت بانکی.',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
settingKey: 'enable_gold_credit',
|
||
|
|
titleFa: 'اعتبار طلایی',
|
||
|
|
description: 'منوی اعتبار و صفحه اعتبار مشتری.',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
settingKey: 'enable_automation',
|
||
|
|
titleFa: 'اتوماسیون',
|
||
|
|
description: 'منوی اتوماسیون در ادمین و موتور پسزمینه.',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
settingKey: 'group_sms',
|
||
|
|
titleFa: 'پیامک گروهی',
|
||
|
|
description: 'ارسال پیامک گروهی از پنل ادمین.',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
settingKey: 'customer_direct_sms',
|
||
|
|
titleFa: 'پیامک تکی به مشتری از لیست',
|
||
|
|
description: 'ارسال متن دلخواه به یک مشتری از لیست.',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
settingKey: 'has_page_notification',
|
||
|
|
titleFa: 'اعلان داخل اپ',
|
||
|
|
description: 'زنگوله اعلان در اپ مشتری و منوی ثبت در ادمین.',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
settingKey: 'has_page_earn_money',
|
||
|
|
titleFa: 'صفحه کسب درآمد',
|
||
|
|
description: 'منوی کسب درآمد / دعوت دوستان در اپ مشتری.',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
settingKey: 'enable_customer_level_profit',
|
||
|
|
titleFa: 'سود چندسطحی معرف',
|
||
|
|
description: 'درصد سود زیرمجموعه پس از سفارش.',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
settingKey: 'enable_conditional_order',
|
||
|
|
titleFa: 'سفارش شرطی',
|
||
|
|
description: 'سفارش شرطی سراسری.',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
settingKey: 'has_page_gift_card',
|
||
|
|
titleFa: 'کارت هدیه',
|
||
|
|
description: 'منو و صفحه کارت هدیه در اپ مشتری.',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
settingKey: 'customer_special_pricing',
|
||
|
|
titleFa: 'قیمت ویژه مشتری',
|
||
|
|
description: 'حاشیه سود/زیان قیمت برای هر مشتری.',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
settingKey: 'enable_product_funds',
|
||
|
|
titleFa: 'قلک محصول',
|
||
|
|
description: 'ساخت و مدیریت قلک per-product در اپ مشتری.',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
settingKey: 'has_page_price_trigger',
|
||
|
|
titleFa: 'هشدار قیمت',
|
||
|
|
description: 'منوی هشدار قیمت در اپ مشتری.',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
settingKey: 'show_to_users_chat',
|
||
|
|
titleFa: 'نمایش چت به کاربران',
|
||
|
|
description: 'نمایش چت پشتیبانی در اپ مشتری.',
|
||
|
|
},
|
||
|
|
];
|
||
|
|
|
||
|
|
export function daysToPlanMonths(days: number): 1 | 3 | 6 | 12 {
|
||
|
|
if (days === 90) return 3;
|
||
|
|
if (days === 180) return 6;
|
||
|
|
if (days === 360) return 12;
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function inferSettingKeyFromName(name: string): string | null {
|
||
|
|
const n = String(name || '').trim();
|
||
|
|
if (!n) return null;
|
||
|
|
const rules: Array<[RegExp, string]> = [
|
||
|
|
[/جیبیت/, 'jibit_enabled'],
|
||
|
|
[/اعتبار طلایی/, 'enable_gold_credit'],
|
||
|
|
[/اتوماسیون/, 'enable_automation'],
|
||
|
|
[/پیامک گروهی/, 'group_sms'],
|
||
|
|
[/پیامک تکی/, 'customer_direct_sms'],
|
||
|
|
[/اعلان/, 'has_page_notification'],
|
||
|
|
[/کسب درآمد/, 'has_page_earn_money'],
|
||
|
|
[/سود.*معرف|معرف/, 'enable_customer_level_profit'],
|
||
|
|
[/سفارش شرطی/, 'enable_conditional_order'],
|
||
|
|
[/کارت هدیه/, 'has_page_gift_card'],
|
||
|
|
[/قیمت ویژه/, 'customer_special_pricing'],
|
||
|
|
[/قلک/, 'enable_product_funds'],
|
||
|
|
[/هشدار قیمت/, 'has_page_price_trigger'],
|
||
|
|
[/نمایش چت|چت به کاربر/, 'show_to_users_chat'],
|
||
|
|
];
|
||
|
|
for (const [re, key] of rules) {
|
||
|
|
if (re.test(n)) return key;
|
||
|
|
}
|
||
|
|
const seed = PLUGIN_CATALOG_SEED.find((row) => row.titleFa === n);
|
||
|
|
return seed?.settingKey ?? null;
|
||
|
|
}
|