- موتور رویدادمحور با شرط، محدودیت، تأیید مدیر و idempotency - اتصال به لید، مشتری، معامله، فعالیت، روتین، پیشفاکتور، فاکتور و تیکت - صفحه /club و /club/admin، اعلان زنده امتیاز، آیتم منو - انتقال فرمساز سرنخ به ابزارها Co-authored-by: Cursor <cursoragent@cursor.com>
91 lines
5.0 KiB
TypeScript
91 lines
5.0 KiB
TypeScript
import type {
|
|
GamificationBadgeMetric,
|
|
GamificationBonusKind,
|
|
GamificationCondition,
|
|
GamificationEvent,
|
|
} from '@mento/shared';
|
|
|
|
type RuleSeed = {
|
|
name: string;
|
|
event: GamificationEvent;
|
|
score: number;
|
|
coins: number;
|
|
conditions?: GamificationCondition[];
|
|
maxPerDay?: number;
|
|
cooldownMinutes?: number;
|
|
oncePerEntity?: boolean;
|
|
};
|
|
|
|
export const DEFAULT_RULES: RuleSeed[] = [
|
|
{ name: 'ثبت لید جدید', event: 'LEAD_CREATED', score: 5, coins: 1, maxPerDay: 40 },
|
|
{ name: 'پیشرفت لید به مرحله بعد', event: 'LEAD_STAGE_CHANGED', score: 10, coins: 2, maxPerDay: 60 },
|
|
{ name: 'تبدیل لید به مشتری', event: 'LEAD_CONVERTED', score: 30, coins: 10, oncePerEntity: true },
|
|
{ name: 'ثبت مشتری جدید', event: 'CUSTOMER_CREATED', score: 20, coins: 5, maxPerDay: 40 },
|
|
{ name: 'ایجاد معامله', event: 'DEAL_CREATED', score: 10, coins: 2, maxPerDay: 30 },
|
|
{ name: 'برنده شدن معامله', event: 'DEAL_WON', score: 50, coins: 20, oncePerEntity: true },
|
|
{ name: 'ثبت تماس', event: 'CALL_LOGGED', score: 2, coins: 0, maxPerDay: 80, cooldownMinutes: 1 },
|
|
{ name: 'ثبت جلسه', event: 'MEETING_CREATED', score: 10, coins: 3, maxPerDay: 10 },
|
|
{ name: 'ثبت پیگیری', event: 'FOLLOW_UP_CREATED', score: 3, coins: 1, maxPerDay: 40 },
|
|
{ name: 'ثبت یادداشت', event: 'NOTE_CREATED', score: 1, coins: 0, maxPerDay: 30 },
|
|
{ name: 'انجام کار', event: 'TASK_COMPLETED', score: 5, coins: 1, maxPerDay: 40 },
|
|
{
|
|
name: 'انجام کار روتین',
|
|
event: 'ROUTINE_COMPLETED',
|
|
score: 2,
|
|
coins: 0,
|
|
conditions: [{ field: 'onTime', op: 'is_false' }],
|
|
},
|
|
{
|
|
name: 'انجام بهموقع کار روتین',
|
|
event: 'ROUTINE_COMPLETED',
|
|
score: 5,
|
|
coins: 1,
|
|
conditions: [{ field: 'onTime', op: 'is_true' }],
|
|
},
|
|
{ name: 'ثبت پیشفاکتور', event: 'QUOTE_CREATED', score: 10, coins: 3, maxPerDay: 20 },
|
|
{ name: 'صدور فاکتور', event: 'INVOICE_ISSUED', score: 15, coins: 5, oncePerEntity: true },
|
|
{ name: 'ثبت پرداخت', event: 'PAYMENT_REGISTERED', score: 20, coins: 5 },
|
|
{ name: 'حل تیکت', event: 'TICKET_RESOLVED', score: 10, coins: 3, oncePerEntity: true },
|
|
];
|
|
|
|
export const DEFAULT_REWARDS = [
|
|
{ name: 'کارت هدیه', description: 'کارت هدیه خرید', cost: 500, icon: 'gift', color: '#14b8a6' },
|
|
{ name: 'ناهار تیمی', description: 'ناهار مهمان شرکت', cost: 800, icon: 'star', color: '#f59e0b' },
|
|
{ name: 'مرخصی تشویقی', description: 'یک روز مرخصی تشویقی', cost: 2000, icon: 'calendar-sun', color: '#8b5cf6' },
|
|
{ name: 'هدفون', description: 'هدفون بیسیم', cost: 3000, icon: 'trophy', color: '#ef4444' },
|
|
];
|
|
|
|
export const DEFAULT_BADGES: Array<{
|
|
name: string;
|
|
description: string;
|
|
icon: string;
|
|
color: string;
|
|
metric: GamificationBadgeMetric;
|
|
event?: GamificationEvent;
|
|
threshold: number;
|
|
coins: number;
|
|
}> = [
|
|
{ name: 'اولین فروش', description: 'اولین معامله برنده', icon: 'trophy', color: '#f59e0b', metric: 'event_count', event: 'DEAL_WON', threshold: 1, coins: 20 },
|
|
{ name: '۱۰ فروش موفق', description: '۱۰ معامله برنده', icon: 'crown', color: '#eab308', metric: 'event_count', event: 'DEAL_WON', threshold: 10, coins: 100 },
|
|
{ name: '۱۰۰ تماس', description: 'ثبت ۱۰۰ تماس', icon: 'phone', color: '#0ea5e9', metric: 'event_count', event: 'CALL_LOGGED', threshold: 100, coins: 50 },
|
|
{ name: '۵۰ مشتری جدید', description: 'ثبت ۵۰ مشتری', icon: 'users', color: '#22c55e', metric: 'event_count', event: 'CUSTOMER_CREATED', threshold: 50, coins: 80 },
|
|
{ name: '۱۰۰ لید', description: 'ثبت ۱۰۰ لید', icon: 'funnel', color: '#14b8a6', metric: 'event_count', event: 'LEAD_CREATED', threshold: 100, coins: 60 },
|
|
{ name: '۳۰ روز روتین کامل', description: '۳۰ روز پیاپی انجام کامل کارهای روتین', icon: 'fire', color: '#f97316', metric: 'routine_streak', threshold: 30, coins: 150 },
|
|
{ name: 'باشگاه هزار امتیازی', description: 'رسیدن به ۱۰۰۰ امتیاز', icon: 'medal', color: '#8b5cf6', metric: 'score_total', threshold: 1000, coins: 50 },
|
|
];
|
|
|
|
export const DEFAULT_BONUSES: Array<{
|
|
name: string;
|
|
description: string;
|
|
kind: GamificationBonusKind;
|
|
event?: GamificationEvent;
|
|
threshold: number;
|
|
period: 'day' | 'week' | 'month';
|
|
score: number;
|
|
coins: number;
|
|
}> = [
|
|
{ name: '۱۰ فروش در ماه', description: '۱۰ معامله برنده در یک ماه', kind: 'event_count_period', event: 'DEAL_WON', threshold: 10, period: 'month', score: 100, coins: 200 },
|
|
{ name: '۵ روز پیاپی روتین کامل', description: 'انجام کامل روتینها در ۵ روز پیاپی', kind: 'routine_streak', threshold: 5, period: 'day', score: 30, coins: 100 },
|
|
{ name: 'نفر اول ماه', description: 'بیشترین امتیاز در ماه', kind: 'top_of_month', threshold: 1, period: 'month', score: 0, coins: 500 },
|
|
];
|