Track person import source and previous names; add source report and edit UX.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-04 12:01:21 +03:30
co-authored by Cursor
parent e144b2277a
commit 8b37525f2f
15 changed files with 632 additions and 25 deletions
+41
View File
@@ -0,0 +1,41 @@
import {
PERSON_IMPORT_SOURCE_LABELS,
PERSON_IMPORT_SOURCES,
type PersonImportSource,
} from '@mento/shared';
export function normalizePersonImportSource(
raw?: string | null,
): PersonImportSource {
const v = String(raw ?? '')
.trim()
.toLowerCase();
if (!v) return 'manual';
if ((PERSON_IMPORT_SOURCES as readonly string[]).includes(v)) {
return v as PersonImportSource;
}
if (/دیدار|didar/.test(v)) return 'didar';
if (/ته.?حساب|tahesab|accounting/.test(v)) return 'tahesab';
if (/اکسل|excel|xlsx|csv/.test(v)) return 'excel';
if (/گوشی|phone|مخاطب|vcard|contact/.test(v)) return 'phone';
if (/لید|lead|فرم/.test(v)) return 'lead_form';
return 'other';
}
export function personImportSourceLabel(source: string): string {
if (source in PERSON_IMPORT_SOURCE_LABELS) {
return PERSON_IMPORT_SOURCE_LABELS[source as PersonImportSource];
}
return source || PERSON_IMPORT_SOURCE_LABELS.manual;
}
export function namesDiffer(
aFirst: string,
aLast: string,
bFirst: string,
bLast: string,
): boolean {
const a = `${aFirst} ${aLast}`.trim().replace(/\s+/g, ' ');
const b = `${bFirst} ${bLast}`.trim().replace(/\s+/g, ' ');
return Boolean(a && b && a !== b);
}