- موتور رویدادمحور با شرط، محدودیت، تأیید مدیر و idempotency - اتصال به لید، مشتری، معامله، فعالیت، روتین، پیشفاکتور، فاکتور و تیکت - صفحه /club و /club/admin، اعلان زنده امتیاز، آیتم منو - انتقال فرمساز سرنخ به ابزارها Co-authored-by: Cursor <cursoragent@cursor.com>
16 lines
833 B
TypeScript
16 lines
833 B
TypeScript
import type { GamificationCondition } from '@mento/shared';
|
|
import { GAMIFICATION_CONDITION_OPS, GAMIFICATION_FIELDS } from '@mento/shared';
|
|
import { toFaDigits } from '@/lib/jalali';
|
|
|
|
/** متن خوانا برای یک شرط، مثل «مبلغ بیشتر از ۱۰۰٬۰۰۰» */
|
|
export function conditionText(c: GamificationCondition): string {
|
|
const field = GAMIFICATION_FIELDS[c.field];
|
|
const label = field?.label ?? c.field;
|
|
if (c.op === 'is_true') return `${label}: بله`;
|
|
if (c.op === 'is_false') return `${label}: خیر`;
|
|
const raw = c.value ?? '';
|
|
const option = field?.options?.find((o) => o.value === String(raw));
|
|
const value = option ? option.label : typeof raw === 'number' ? toFaDigits(raw.toLocaleString('en-US')) : String(raw);
|
|
return `${label} ${GAMIFICATION_CONDITION_OPS[c.op]} ${value}`;
|
|
}
|