Add after-hours callbacks and persistent ad attribution to all four landings

- The callback dialog switches its copy outside business hours
  (shared/business-hours.ts); such leads get a "нерабочее время" tag,
  a marker in the deal name and a line in the note in amoCRM.
- utm_*, yclid and gclid are read on page load and kept for 30 days
  (src/lib/attribution.ts), last tagged visit wins, and are sent with
  every lead.
- The callback dialog is rebuilt: focus trap, focus return, phone
  masking and a full-number check.
- fitnes drops the floating MobileCta; header and mobile bars follow
  the new dialog state in the other three.
- Add the latest design mockups under legacy/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
yuriy.pandClaude Opus 5.5 committed 2026-09-23 20:53:40 +06:00
1 parent 56ff5839b8
commit a61d53962a
145 files changed
+9242 -523

No files matched your search

+22 -2
View File
@@ -1,3 +1,4 @@
import { businessHours } from '../../shared/business-hours.ts'
import type { CallClickPayload, LeadPayload } from '../../shared/lead.ts'
import type { AmoCustomField, AmoFieldEntry } from './amocrm.ts'
@@ -18,6 +19,8 @@ const LABELS: Record<string, string> = {
utm_campaign: 'utm_campaign',
utm_content: 'utm_content',
utm_term: 'utm_term',
yclid: 'yclid',
gclid: 'gclid',
}
/**
@@ -39,6 +42,8 @@ const CANDIDATES: Record<string, { codes: string[]; names: string[] }> = {
utm_campaign: { codes: ['UTM_CAMPAIGN'], names: ['utm_campaign'] },
utm_content: { codes: ['UTM_CONTENT'], names: ['utm_content'] },
utm_term: { codes: ['UTM_TERM'], names: ['utm_term'] },
yclid: { codes: ['YCLID'], names: ['yclid'] },
gclid: { codes: ['GCLID'], names: ['gclid'] },
}
/** Field types we know how to write a plain string into. */
@@ -133,7 +138,7 @@ export function mapLead(payload: LeadPayload, fieldMap: LeadFieldMap): MappedLea
comment: payload.comment,
page: payload.page,
referrer: payload.referrer,
form: payload.form === 'callback' ? 'Быстрый обратный звонок' : 'Заявка на усиление кабинета физиотерапии',
form: formLabel(payload),
...payload.utm,
}
@@ -145,15 +150,30 @@ export function mapLead(payload: LeadPayload, fieldMap: LeadFieldMap): MappedLea
`Заявка с лендинга «${LANDING}»`,
`${LABELS.phone}: ${payload.phone}`,
payload.email ? `${LABELS.email}: ${payload.email}` : undefined,
payload.after_hours
? `Оставлена в нерабочее время (${businessHours.label}) — посетителю обещан звонок в ближайшее рабочее время.`
: undefined,
].filter(Boolean) as string[]
return { fields, note: [...header, ...leftovers].join('\n') }
}
function formLabel(payload: LeadPayload): string {
if (payload.form === 'request') return 'Заявка на усиление кабинета физиотерапии'
return payload.after_hours ? 'Обратный звонок в нерабочее время' : 'Быстрый обратный звонок'
}
/** Lead title shown in the pipeline. */
export function buildLeadName(payload: LeadPayload): string {
const who = payload.company ?? payload.name
return payload.form === 'callback' ? `Обратный звонок — ${who}` : `Физиотерапия — ${who}`
if (payload.form === 'request') return `Физиотерапия — ${who}`
return payload.after_hours ? `Обратный звонок (нерабочее время) — ${who}` : `Обратный звонок — ${who}`
}
/** Form tag, plus a second one that lets managers filter overnight callbacks. */
export function buildLeadTags(payload: LeadPayload): string[] {
if (payload.form === 'request') return ['заявка с сайта']
return payload.after_hours ? ['обратный звонок', 'нерабочее время'] : ['обратный звонок']
}
/**
+2 -1
View File
@@ -3,6 +3,7 @@ import { AmoClient, type AmoContact, type AmoFieldEntry } from './amocrm.ts'
import {
buildCallClickName,
buildLeadName,
buildLeadTags,
mapCallClick,
mapLead,
resolveLeadFieldMap,
@@ -115,7 +116,7 @@ export class LeadService {
name: buildLeadName(payload),
contactId,
fields,
tags: [payload.form === 'callback' ? 'обратный звонок' : 'заявка с сайта'],
tags: buildLeadTags(payload),
})
// 3. Everything the account has no field for lands in a readable note.