1
0
forked from Yara724/api
Files
yara724-api/src/helpers/expert-profile-snapshot.ts
2026-04-20 18:19:25 +03:30

30 lines
1.0 KiB
TypeScript

import { ExpertModel } from "src/users/entities/schema/expert.schema";
import { DamageExpertModel } from "src/users/entities/schema/damage-expert.schema";
import { ExpertProfileSnapshot } from "src/request-management/entities/schema/expert-profile-snapshot.schema";
export function snapshotFromFieldExpert(
doc: ExpertModel | null | undefined,
): ExpertProfileSnapshot | undefined {
if (!doc) return undefined;
return {
firstName: doc.firstName ?? undefined,
lastName: doc.lastName ?? undefined,
email: doc.email ?? undefined,
insuActivityCo: doc.insuActivityCo ?? undefined,
mobile: (doc.mobile ?? doc.phone) ?? undefined,
};
}
export function snapshotFromDamageExpert(
doc: DamageExpertModel | null | undefined,
): ExpertProfileSnapshot | undefined {
if (!doc) return undefined;
return {
firstName: doc.firstName ?? undefined,
lastName: doc.lastName ?? undefined,
email: doc.email ?? undefined,
insuActivityCo: doc.insuActivityCo ?? undefined,
mobile: doc.mobile ?? undefined,
};
}