Fixed unified data in insurer as well

This commit is contained in:
SepehrYahyaee
2026-06-03 12:55:15 +03:30
parent bd5a33e2ba
commit 8236f0440d

View File

@@ -55,6 +55,7 @@ import {
extractExpertNamesFromBlame, extractExpertNamesFromBlame,
extractExpertNamesFromClaim, extractExpertNamesFromClaim,
} from "./helper/insurer.helper"; } from "./helper/insurer.helper";
import { buildEnrichedDamagedParts } from "src/expert-claim/dto/claim-damaged-part.enricher";
@Injectable() @Injectable()
export class ExpertInsurerService { export class ExpertInsurerService {
@@ -580,6 +581,28 @@ export class ExpertInsurerService {
claim: Record<string, unknown>, claim: Record<string, unknown>,
blameForContext: Record<string, unknown> | null, blameForContext: Record<string, unknown> | null,
): Promise<Record<string, unknown>> { ): Promise<Record<string, unknown>> {
// Add at the top of buildInsurerClaimDetail, before the return:
const carType = (claim as any).vehicle?.carType as
| ClaimVehicleTypeV2
| undefined;
const selectedNorm = normalizeDamageSelectedParts(
(claim as any).damage?.selectedParts,
carType,
(claim as any).damage?.selectedOuterParts,
);
const damagedParts = buildEnrichedDamagedParts({
selectedParts: selectedNorm,
damagedPartsData: (claim as any).media?.damagedParts,
evaluationBlock: (claim as any).evaluation,
expertAddedParts: (claim as any).damage?.expertAddedParts ?? [],
getDamagedPartCaptureBlob,
hasDamagedPartCapture,
catalogLikeKeyFromPart,
buildFileLink,
});
// Then add damagedParts to the return object
const requiredDocs = claim.requiredDocuments as any; const requiredDocs = claim.requiredDocuments as any;
const requiredDocumentsStatus: Record<string, any> = {}; const requiredDocumentsStatus: Record<string, any> = {};
if (requiredDocs) { if (requiredDocs) {
@@ -614,32 +637,6 @@ export class ExpertInsurerService {
}; };
} }
const carTypeExpert = (claim.vehicle as any)?.carType as
| ClaimVehicleTypeV2
| undefined;
const selectedNormExpert = normalizeDamageSelectedParts(
(claim.damage as any)?.selectedParts,
carTypeExpert,
(claim.damage as any)?.selectedOuterParts,
);
const damagedPartsDataExpert = (claim.media as any)?.damagedParts;
const damagedParts = selectedNormExpert.map((sp, index) =>
this.insurerDamagedPartRowFromCapture(
sp,
index,
damagedPartsDataExpert,
selectedNormExpert,
),
);
const selectedPartsNormalized = selectedNormExpert.map((sp, index) =>
this.insurerDamagedPartRowFromCapture(
sp,
index,
damagedPartsDataExpert,
selectedNormExpert,
),
);
const videoCaptureIdRaw = (claim.media as any)?.videoCaptureId; const videoCaptureIdRaw = (claim.media as any)?.videoCaptureId;
let videoCapture: let videoCapture:
| { id: string; fileName?: string; path?: string; url?: string } | { id: string; fileName?: string; path?: string; url?: string }
@@ -724,7 +721,6 @@ export class ExpertInsurerService {
: undefined, : undefined,
carAngles, carAngles,
damagedParts, damagedParts,
selectedPartsNormalized,
videoCapture, videoCapture,
evaluation: evaluationEnriched, evaluation: evaluationEnriched,
userRating: claim.userRating, userRating: claim.userRating,