Connect public lead forms to CRM Leads on submit.
This commit is contained in:
@@ -23,10 +23,21 @@ const MAP_TO = [
|
||||
'person.position',
|
||||
'deal.title',
|
||||
'deal.notes',
|
||||
'lead.title',
|
||||
'lead.contactName',
|
||||
'lead.mobile',
|
||||
'lead.phone',
|
||||
'lead.city',
|
||||
'lead.region',
|
||||
'lead.trade',
|
||||
'lead.notes',
|
||||
'lead.source',
|
||||
'notes',
|
||||
'custom',
|
||||
] as const;
|
||||
|
||||
const DUPLICATE_MODES = ['skip', 'update', 'activity'] as const;
|
||||
|
||||
export class LeadFormFieldInputDto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@@ -74,6 +85,10 @@ export class CreateLeadFormDto {
|
||||
@MaxLength(400)
|
||||
description?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
createLead?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
createPerson?: boolean;
|
||||
@@ -86,6 +101,14 @@ export class CreateLeadFormDto {
|
||||
@IsString()
|
||||
pipelineId?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
leadStageId?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsIn(DUPLICATE_MODES)
|
||||
duplicateMode?: (typeof DUPLICATE_MODES)[number];
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(80)
|
||||
@@ -141,6 +164,10 @@ export class UpdateLeadFormDto {
|
||||
@IsBoolean()
|
||||
isActive?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
createLead?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
createPerson?: boolean;
|
||||
@@ -153,6 +180,14 @@ export class UpdateLeadFormDto {
|
||||
@IsString()
|
||||
pipelineId?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
leadStageId?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsIn(DUPLICATE_MODES)
|
||||
duplicateMode?: (typeof DUPLICATE_MODES)[number];
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(80)
|
||||
@@ -192,7 +227,70 @@ export class UpdateLeadFormDto {
|
||||
fields?: LeadFormFieldInputDto[];
|
||||
}
|
||||
|
||||
export class LeadFormUtmDto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(120)
|
||||
source?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(120)
|
||||
medium?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(160)
|
||||
campaign?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(160)
|
||||
term?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(160)
|
||||
content?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(500)
|
||||
landingPage?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(500)
|
||||
referrer?: string;
|
||||
}
|
||||
|
||||
export class SubmitLeadFormDto {
|
||||
@IsObject()
|
||||
values!: Record<string, string>;
|
||||
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => LeadFormUtmDto)
|
||||
utm?: LeadFormUtmDto;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(1000)
|
||||
pageUrl?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(1000)
|
||||
referrer?: string;
|
||||
|
||||
/** honeypot */
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(200)
|
||||
website?: string;
|
||||
}
|
||||
|
||||
export class LeadFormPublicEventDto {
|
||||
@IsIn(['view', 'start'])
|
||||
type!: 'view' | 'start';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user