diff --git a/src/lib/bitrix24/leads.ts b/src/lib/bitrix24/leads.ts index f908f2f..89cc4ad 100644 --- a/src/lib/bitrix24/leads.ts +++ b/src/lib/bitrix24/leads.ts @@ -20,6 +20,31 @@ interface BitrixMultiField { VALUE: string } +// The form submits stable option ids; the CRM should show the same Russian +// labels the user sees in the UI (see ContactForm.tsx). Unknown ids fall +// through unchanged. +const PURPOSE_LABELS: Record = { + modernization: 'Модернизация инфраструктуры', + 'software-replacement': 'Замена импортного ПО на российское', + 'capacity-expansion': 'Расширение мощностей', + 'new-infrastructure': 'Создание новой инфраструктуры', + 'security-improvement': 'Повышение безопасности', + automation: 'Автоматизация процессов', + 'cloud-migration': 'Миграция в облако', + 'disaster-recovery': 'Резервирование и восстановление', + compliance: 'Соответствие требованиям регуляторов', + other: 'Другое', +} + +const TIMELINE_LABELS: Record = { + urgent: 'До 1 месяца', + '1-3-months': '1-3 месяца', + '3-6-months': '3-6 месяцев', + '6-12-months': '6-12 месяцев', + '12-months-plus': 'Более 12 месяцев', + planning: 'На стадии планирования', +} + /** Lead fields sent to `crm.lead.add`. UF_CRM_* are mapped form fields (see consts above). */ interface BitrixLeadFields { SOURCE_ID: string @@ -96,10 +121,10 @@ function toLeadFields(submission: ContactSubmission): BitrixLeadFields { if (company) fields[UF_COMPANY] = company const purpose = trimmed(submission.purpose) - if (purpose) fields[UF_PURPOSE] = purpose + if (purpose) fields[UF_PURPOSE] = PURPOSE_LABELS[purpose] ?? purpose const timeline = trimmed(submission.timeline) - if (timeline) fields[UF_TIMELINE] = timeline + if (timeline) fields[UF_TIMELINE] = TIMELINE_LABELS[timeline] ?? timeline const meetingSlot = trimmed(submission.meetingSlot1) if (meetingSlot) fields[UF_MEETING_SLOT] = toBitrixDateTime(meetingSlot)