Add optional activity experience on leads and people with form mapping and filters.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-19 21:04:43 +03:30
co-authored by Cursor
parent e90f9f9538
commit a455ab71ab
19 changed files with 430 additions and 20 deletions
+75
View File
@@ -1491,6 +1491,74 @@ export const PERSON_IMPORT_SOURCE_LABELS: Record<PersonImportSource, string> = {
other: "سایر",
};
/** گزینه‌های ثابت فیلد «سابقه فعالیت» برای لید و مشتری */
export const ACTIVITY_EXPERIENCE_OPTIONS = [
"ندارم",
"1 الی 2 سال",
"2 الی 5 سال",
"بیش از 5 سال",
] as const;
export type ActivityExperience = (typeof ACTIVITY_EXPERIENCE_OPTIONS)[number];
/** نرمال‌سازی جواب فرم/ویرایش به یکی از گزینه‌های ثابت */
export function normalizeActivityExperience(
raw: string | null | undefined,
): ActivityExperience | null {
const text = (raw ?? "")
.trim()
.replace(/[۰-۹]/g, (d) => String("۰۱۲۳۴۵۶۷۸۹".indexOf(d)))
.replace(/[٠-٩]/g, (d) => String("٠١٢٣٤٥٦٧٨٩".indexOf(d)))
.replace(/\s+/g, " ");
if (!text) return null;
const lower = text.replace(/ي/g, "ی").replace(/ك/g, "ک").toLowerCase();
if (
lower === "ندارم" ||
lower === "ندارد" ||
lower.includes("بدون سابقه") ||
lower === "0" ||
lower === "هیچ"
) {
return "ندارم";
}
if (
lower.includes("بیش از 5") ||
lower.includes("بیشتر از 5") ||
lower.includes("بالای 5") ||
lower.includes("+5") ||
lower.includes("5 سال به بالا")
) {
return "بیش از 5 سال";
}
if (
lower.includes("2 الی 5") ||
lower.includes("2 تا 5") ||
lower.includes("۲ الی ۵") ||
lower.includes("2-5") ||
lower.includes("2–5")
) {
return "2 الی 5 سال";
}
if (
lower.includes("1 الی 2") ||
lower.includes("1 تا 2") ||
lower.includes("۱ الی ۲") ||
lower.includes("1-2") ||
lower.includes("1–2")
) {
return "1 الی 2 سال";
}
for (const option of ACTIVITY_EXPERIENCE_OPTIONS) {
if (lower === option.toLowerCase()) return option;
}
return null;
}
/** برچسب سؤال فرم که به فیلد سابقه فعالیت مربوط است */
export function isActivityExperienceLabel(label: string): boolean {
const text = label.trim().replace(/ي/g, "ی").replace(/ك/g, "ک");
return /سابقه\s*فعالیت/.test(text);
}
export interface PersonImportSourceStatDto {
source: PersonImportSource | string;
label: string;
@@ -1520,6 +1588,7 @@ export interface PersonDto {
instagram: string | null;
birthDate: string | null;
referrer: string | null;
activityExperience: string | null;
addresses: string[];
notes: string | null;
mood: PersonMood;
@@ -1555,6 +1624,7 @@ export interface CreatePersonRequest {
instagram?: string;
birthDate?: string | null;
referrer?: string;
activityExperience?: string | null;
addresses?: string[];
notes?: string;
mood?: PersonMood;
@@ -2912,9 +2982,11 @@ export type LeadFormMapTo =
| "lead.city"
| "lead.region"
| "lead.trade"
| "lead.activityExperience"
| "lead.notes"
| "lead.source"
| "lead.gender"
| "person.activityExperience"
| "person.gender"
| "notes"
| "custom";
@@ -6289,6 +6361,7 @@ export interface LeadDto {
addresses: string[];
trade: string | null;
source: string | null;
activityExperience: string | null;
notes: string | null;
estimatedValue: number | null;
stageId: string;
@@ -6330,6 +6403,7 @@ export interface CreateLeadRequest {
addresses?: string[];
trade?: string | null;
source?: string | null;
activityExperience?: string | null;
notes?: string | null;
estimatedValue?: number | null;
stageId?: string;
@@ -6353,6 +6427,7 @@ export interface UpdateLeadRequest {
addresses?: string[];
trade?: string | null;
source?: string | null;
activityExperience?: string | null;
notes?: string | null;
estimatedValue?: number | null;
stageId?: string;