2026-08-29 21:06:30 +03:30
|
|
|
import {
|
|
|
|
|
ArrayMaxSize,
|
|
|
|
|
IsArray,
|
|
|
|
|
IsBoolean,
|
|
|
|
|
IsIn,
|
|
|
|
|
IsObject,
|
|
|
|
|
IsOptional,
|
|
|
|
|
IsString,
|
|
|
|
|
MaxLength,
|
|
|
|
|
MinLength,
|
|
|
|
|
ValidateNested,
|
|
|
|
|
} from 'class-validator';
|
|
|
|
|
import { Type } from 'class-transformer';
|
2026-09-06 13:50:05 +03:30
|
|
|
import { LEAD_FORM_FIELD_TYPES } from '@mento/shared';
|
2026-08-29 21:06:30 +03:30
|
|
|
|
|
|
|
|
const MAP_TO = [
|
|
|
|
|
'person.firstName',
|
|
|
|
|
'person.lastName',
|
2026-09-06 13:50:05 +03:30
|
|
|
'person.fullName',
|
2026-08-29 21:06:30 +03:30
|
|
|
'person.email',
|
|
|
|
|
'person.mobile',
|
|
|
|
|
'person.phone',
|
|
|
|
|
'person.position',
|
|
|
|
|
'deal.title',
|
|
|
|
|
'deal.notes',
|
|
|
|
|
'notes',
|
2026-09-06 13:50:05 +03:30
|
|
|
'custom',
|
2026-08-29 21:06:30 +03:30
|
|
|
] as const;
|
|
|
|
|
|
|
|
|
|
export class LeadFormFieldInputDto {
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
@MaxLength(64)
|
|
|
|
|
key?: string;
|
|
|
|
|
|
|
|
|
|
@IsString()
|
|
|
|
|
@MinLength(1)
|
|
|
|
|
@MaxLength(120)
|
|
|
|
|
label!: string;
|
|
|
|
|
|
2026-09-06 13:50:05 +03:30
|
|
|
@IsIn([...LEAD_FORM_FIELD_TYPES])
|
|
|
|
|
fieldType!: (typeof LEAD_FORM_FIELD_TYPES)[number];
|
2026-08-29 21:06:30 +03:30
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsBoolean()
|
|
|
|
|
required?: boolean;
|
|
|
|
|
|
|
|
|
|
@IsIn(MAP_TO)
|
|
|
|
|
mapTo!: (typeof MAP_TO)[number];
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
position?: number;
|
2026-09-06 13:50:05 +03:30
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
@MaxLength(160)
|
|
|
|
|
placeholder?: string | null;
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsArray()
|
|
|
|
|
@IsString({ each: true })
|
|
|
|
|
@ArrayMaxSize(40)
|
|
|
|
|
options?: string[];
|
2026-08-29 21:06:30 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class CreateLeadFormDto {
|
|
|
|
|
@IsString()
|
|
|
|
|
@MinLength(2)
|
|
|
|
|
@MaxLength(120)
|
|
|
|
|
name!: string;
|
|
|
|
|
|
2026-09-06 13:50:05 +03:30
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
@MaxLength(400)
|
|
|
|
|
description?: string | null;
|
|
|
|
|
|
2026-08-29 21:06:30 +03:30
|
|
|
@IsOptional()
|
|
|
|
|
@IsBoolean()
|
|
|
|
|
createPerson?: boolean;
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsBoolean()
|
|
|
|
|
createDeal?: boolean;
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
pipelineId?: string | null;
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
@MaxLength(80)
|
|
|
|
|
source?: string | null;
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
@MaxLength(500)
|
|
|
|
|
thankYouMessage?: string | null;
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
@MaxLength(500)
|
|
|
|
|
redirectUrl?: string | null;
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsArray()
|
|
|
|
|
@IsString({ each: true })
|
|
|
|
|
@ArrayMaxSize(50)
|
|
|
|
|
assigneeIds?: string[];
|
|
|
|
|
|
2026-09-06 13:50:05 +03:30
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
@MaxLength(80)
|
|
|
|
|
submitLabel?: string;
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
@MaxLength(20)
|
|
|
|
|
submitColor?: string;
|
|
|
|
|
|
2026-08-29 21:06:30 +03:30
|
|
|
@IsOptional()
|
|
|
|
|
@IsArray()
|
|
|
|
|
@ValidateNested({ each: true })
|
|
|
|
|
@Type(() => LeadFormFieldInputDto)
|
2026-09-06 13:50:05 +03:30
|
|
|
@ArrayMaxSize(40)
|
2026-08-29 21:06:30 +03:30
|
|
|
fields?: LeadFormFieldInputDto[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class UpdateLeadFormDto {
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
@MinLength(2)
|
|
|
|
|
@MaxLength(120)
|
|
|
|
|
name?: string;
|
|
|
|
|
|
2026-09-06 13:50:05 +03:30
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
@MaxLength(400)
|
|
|
|
|
description?: string | null;
|
|
|
|
|
|
2026-08-29 21:06:30 +03:30
|
|
|
@IsOptional()
|
|
|
|
|
@IsBoolean()
|
|
|
|
|
isActive?: boolean;
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsBoolean()
|
|
|
|
|
createPerson?: boolean;
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsBoolean()
|
|
|
|
|
createDeal?: boolean;
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
pipelineId?: string | null;
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
@MaxLength(80)
|
|
|
|
|
source?: string | null;
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
@MaxLength(500)
|
|
|
|
|
thankYouMessage?: string | null;
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
@MaxLength(500)
|
|
|
|
|
redirectUrl?: string | null;
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsArray()
|
|
|
|
|
@IsString({ each: true })
|
|
|
|
|
@ArrayMaxSize(50)
|
|
|
|
|
assigneeIds?: string[];
|
|
|
|
|
|
2026-09-06 13:50:05 +03:30
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
@MaxLength(80)
|
|
|
|
|
submitLabel?: string;
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
@MaxLength(20)
|
|
|
|
|
submitColor?: string;
|
|
|
|
|
|
2026-08-29 21:06:30 +03:30
|
|
|
@IsOptional()
|
|
|
|
|
@IsArray()
|
|
|
|
|
@ValidateNested({ each: true })
|
|
|
|
|
@Type(() => LeadFormFieldInputDto)
|
2026-09-06 13:50:05 +03:30
|
|
|
@ArrayMaxSize(40)
|
2026-08-29 21:06:30 +03:30
|
|
|
fields?: LeadFormFieldInputDto[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class SubmitLeadFormDto {
|
|
|
|
|
@IsObject()
|
|
|
|
|
values!: Record<string, string>;
|
|
|
|
|
}
|