Add optional activity experience on leads and people with form mapping and filters.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -100,6 +100,12 @@ export class ListQueryDto {
|
||||
@IsString()
|
||||
@MaxLength(2000)
|
||||
groupId?: string;
|
||||
|
||||
/** فیلتر سابقه فعالیت؛ چندتایی با کاما */
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(400)
|
||||
activityExperience?: string;
|
||||
}
|
||||
|
||||
class CompanyExtraFieldsDto {
|
||||
@@ -360,6 +366,11 @@ export class CreatePersonDto {
|
||||
@MaxLength(120)
|
||||
referrer?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(80)
|
||||
activityExperience?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
@@ -486,6 +497,11 @@ export class UpdatePersonDto {
|
||||
@MaxLength(120)
|
||||
referrer?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(80)
|
||||
activityExperience?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
|
||||
@@ -63,6 +63,7 @@ export class PeopleController {
|
||||
hasMobile,
|
||||
disc: query.disc,
|
||||
groupId: query.groupId,
|
||||
activityExperience: query.activityExperience,
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -81,6 +82,7 @@ export class PeopleController {
|
||||
hasMobile,
|
||||
disc: query.disc,
|
||||
groupId: query.groupId,
|
||||
activityExperience: query.activityExperience,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
PERSON_MOODS,
|
||||
applyPersonGenderTitle,
|
||||
canViewAllRecords,
|
||||
normalizeActivityExperience,
|
||||
splitPersonHonorific,
|
||||
} from '@mento/shared';
|
||||
import { Prisma } from '@prisma/client';
|
||||
@@ -102,6 +103,7 @@ type PersonRow = {
|
||||
instagram: string | null;
|
||||
birthDate: Date | null;
|
||||
referrer: string | null;
|
||||
activityExperience: string | null;
|
||||
addresses: unknown;
|
||||
notes: string | null;
|
||||
mood: PersonMood;
|
||||
@@ -174,6 +176,7 @@ export class PeopleService implements OnModuleInit {
|
||||
hasMobile?: boolean;
|
||||
disc?: string;
|
||||
groupId?: string;
|
||||
activityExperience?: string;
|
||||
},
|
||||
): Prisma.PersonWhereInput {
|
||||
const sources = [...new Set(splitCsv(opts?.importSource).map(normalizePersonImportSource))];
|
||||
@@ -181,6 +184,7 @@ export class PeopleService implements OnModuleInit {
|
||||
(PERSON_MOODS as readonly string[]).includes(m),
|
||||
);
|
||||
const groupIds = splitCsv(opts?.groupId);
|
||||
const experiences = splitCsv(opts?.activityExperience);
|
||||
const search = buildSearchWhere<Prisma.PersonWhereInput>(q, (t) => [
|
||||
{ firstName: ci(t) },
|
||||
{ lastName: ci(t) },
|
||||
@@ -231,6 +235,9 @@ export class PeopleService implements OnModuleInit {
|
||||
if (sources.length) {
|
||||
facets.push({ importSource: { in: sources } });
|
||||
}
|
||||
if (experiences.length) {
|
||||
facets.push({ activityExperience: { in: experiences } });
|
||||
}
|
||||
if (facets.length === 1) and.push(facets[0]!);
|
||||
else if (facets.length > 1) and.push({ OR: facets });
|
||||
return {
|
||||
@@ -258,6 +265,7 @@ export class PeopleService implements OnModuleInit {
|
||||
hasMobile?: boolean;
|
||||
disc?: string;
|
||||
groupId?: string;
|
||||
activityExperience?: string;
|
||||
},
|
||||
): Promise<PaginatedResponse<PersonDto>> {
|
||||
const seeDisc = await this.behaviorAccess.canView(actor);
|
||||
@@ -296,6 +304,7 @@ export class PeopleService implements OnModuleInit {
|
||||
hasMobile?: boolean;
|
||||
disc?: string;
|
||||
groupId?: string;
|
||||
activityExperience?: string;
|
||||
},
|
||||
max = FILTERED_IDS_MAX,
|
||||
): Promise<FilteredIdsResponse> {
|
||||
@@ -475,6 +484,9 @@ export class PeopleService implements OnModuleInit {
|
||||
instagram: emptyToNull(dto.instagram),
|
||||
birthDate: parseBirthDate(dto.birthDate),
|
||||
referrer: emptyToNull(dto.referrer),
|
||||
activityExperience:
|
||||
normalizeActivityExperience(dto.activityExperience) ??
|
||||
emptyToNull(dto.activityExperience),
|
||||
addresses: toJsonAddresses(dto.addresses),
|
||||
notes: emptyToNull(dto.notes),
|
||||
mood: dto.mood ?? 'newcomer',
|
||||
@@ -587,6 +599,11 @@ export class PeopleService implements OnModuleInit {
|
||||
if ('instagram' in dto) data.instagram = emptyToNull(dto.instagram);
|
||||
if ('birthDate' in dto) data.birthDate = parseBirthDate(dto.birthDate);
|
||||
if ('referrer' in dto) data.referrer = emptyToNull(dto.referrer);
|
||||
if ('activityExperience' in dto) {
|
||||
data.activityExperience =
|
||||
normalizeActivityExperience(dto.activityExperience) ??
|
||||
emptyToNull(dto.activityExperience);
|
||||
}
|
||||
if ('addresses' in dto) data.addresses = toJsonAddresses(dto.addresses);
|
||||
if ('notes' in dto) data.notes = emptyToNull(dto.notes);
|
||||
if (dto.mood !== undefined) data.mood = dto.mood;
|
||||
@@ -1022,6 +1039,7 @@ export class PeopleService implements OnModuleInit {
|
||||
instagram: row.instagram,
|
||||
birthDate: row.birthDate?.toISOString() ?? null,
|
||||
referrer: row.referrer,
|
||||
activityExperience: row.activityExperience,
|
||||
addresses: (() => {
|
||||
const fromCol = asAddresses(row.addresses);
|
||||
if (fromCol.length) return fromCol;
|
||||
|
||||
Reference in New Issue
Block a user