Rename the two medcenter landings to their audience names: medcenter -> medcenterphysio, medcenterpersonal -> medcenterstart. Alongside the rename: - add a RevenueCalculator section to both landings; - rework the copy and figures in src/data/content.ts; - simplify the lead form: drop the "cabinet_state" and "profile" selects (along with SelectField and the matching fields in shared/lead.ts, lead-mapper.ts and amo-check.ts) and make company and email optional; - add the legacy/new static prototypes for both landings; - add pnpm-lock.yaml to medcenterstart (package-lock.json is still there too). deploy/apps.conf and deploy/README.md still refer to the old directory names and need a follow-up. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
67 lines
2.2 KiB
TypeScript
67 lines
2.2 KiB
TypeScript
/**
|
|
* Verifies the amoCRM connection and prints what the integration will do with
|
|
* your account: which pipeline stage leads land in, and which of your custom
|
|
* fields the lead form's data was matched to.
|
|
*
|
|
* npm run amo:check
|
|
*/
|
|
import { AmoClient } from '../server/src/amocrm.ts'
|
|
import { readAmoConfig } from '../server/src/config.ts'
|
|
import { resolveLeadFieldMap } from '../server/src/lead-mapper.ts'
|
|
|
|
const config = readAmoConfig()
|
|
if (!config) {
|
|
console.error('✗ AMO_SUBDOMAIN and AMO_LONG_LIVED_TOKEN must be set in .env')
|
|
process.exit(1)
|
|
}
|
|
|
|
const amo = new AmoClient(config)
|
|
|
|
console.info(`→ ${config.baseUrl}\n`)
|
|
|
|
const account = await amo.getAccount()
|
|
console.info(`✓ Account: ${account?.name} (id ${account?.id})`)
|
|
|
|
const pipeline = await amo.getPipeline(config.pipelineId)
|
|
if (!pipeline) {
|
|
console.error(`✗ Pipeline ${config.pipelineId} not found in this account.`)
|
|
process.exit(1)
|
|
}
|
|
|
|
const stages = [...(pipeline._embedded?.statuses ?? [])].sort((a, b) => a.sort - b.sort)
|
|
console.info(`✓ Pipeline ${pipeline.id}: «${pipeline.name}»`)
|
|
console.info(` Leads will be created in the first stage: «${stages[0]?.name ?? 'unknown'}»`)
|
|
console.info(` All stages: ${stages.map((s) => s.name).join(' → ')}\n`)
|
|
|
|
const leadFields = await amo.getLeadFields()
|
|
const map = resolveLeadFieldMap(leadFields)
|
|
|
|
console.info(`Lead data → amoCRM field mapping (${leadFields.length} custom fields in the account):`)
|
|
const keys = [
|
|
'company',
|
|
'profile',
|
|
'comment',
|
|
'page',
|
|
'referrer',
|
|
'form',
|
|
'utm_source',
|
|
'utm_medium',
|
|
'utm_campaign',
|
|
'utm_content',
|
|
'utm_term',
|
|
]
|
|
for (const key of keys) {
|
|
const field = map.get(key)
|
|
console.info(
|
|
field
|
|
? ` ✓ ${key.padEnd(14)} → «${field.name}» (id ${field.id}, ${field.type})`
|
|
: ` · ${key.padEnd(14)} → note on the lead`,
|
|
)
|
|
}
|
|
|
|
const contactFields = await amo.getContactFields()
|
|
const hasPhone = contactFields.some((f) => f.code === 'PHONE')
|
|
const hasEmail = contactFields.some((f) => f.code === 'EMAIL')
|
|
console.info(`\nContact fields: PHONE ${hasPhone ? '✓' : '✗ missing'}, EMAIL ${hasEmail ? '✓' : '✗ missing'}`)
|
|
console.info('\nAll good — the form is ready to create leads.')
|