forked from Yara724/api
YARA-850
This commit is contained in:
@@ -84,6 +84,7 @@ import {
|
||||
normalizeDamageSelectedParts,
|
||||
partIdentityKey,
|
||||
partIdentityKeyFromCarPartDamage,
|
||||
resolveSelectedPartByPartId,
|
||||
} from "src/helpers/outer-damage-parts";
|
||||
import { ClaimVehicleTypeV2 } from "src/static/outer-car-parts-catalog";
|
||||
import { snapshotFromDamageExpert } from "src/helpers/expert-profile-snapshot";
|
||||
@@ -2698,13 +2699,29 @@ export class ExpertClaimService {
|
||||
const processedParts = daghiNormalized.map((p) => {
|
||||
let carPartDamage: Record<string, unknown>;
|
||||
try {
|
||||
const selected = resolveSelectedPartByPartId(
|
||||
p.partId,
|
||||
ownerSelectedParts,
|
||||
);
|
||||
if (!selected) {
|
||||
throw new BadRequestException(
|
||||
`Unknown partId "${p.partId}". Use partId from claim detail damagedParts (after editing parts on the claim).`,
|
||||
);
|
||||
}
|
||||
carPartDamage = normalizeCarPartDamageForExpertReply(
|
||||
p.carPartDamage as unknown,
|
||||
{
|
||||
id: selected.id,
|
||||
name: selected.name,
|
||||
side: selected.side,
|
||||
label_fa: selected.label_fa,
|
||||
...(selected.catalogKey ? { catalogKey: selected.catalogKey } : {}),
|
||||
},
|
||||
carTypeSubmit,
|
||||
);
|
||||
} catch (err) {
|
||||
if (err instanceof BadRequestException) throw err;
|
||||
throw new BadRequestException(
|
||||
`Invalid carPartDamage for part ${p.partId}: ${
|
||||
`Invalid part ${p.partId}: ${
|
||||
err instanceof Error ? err.message : String(err)
|
||||
}`,
|
||||
);
|
||||
@@ -2713,7 +2730,7 @@ export class ExpertClaimService {
|
||||
const identityKey = partIdentityKeyFromCarPartDamage(carPartDamage);
|
||||
if (!identityKey) {
|
||||
throw new BadRequestException(
|
||||
`Invalid carPartDamage for part ${p.partId}: cannot derive a stable identity (need a catalog id or both name and side).`,
|
||||
`Invalid part ${p.partId}: cannot derive a stable identity (need a catalog id or both name and side).`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3537,6 +3554,7 @@ export class ExpertClaimService {
|
||||
) as { url?: string; path?: string } | undefined;
|
||||
return {
|
||||
index,
|
||||
partId: partIdentityKey(sp),
|
||||
id: sp.id,
|
||||
name: sp.name,
|
||||
side: sp.side,
|
||||
|
||||
Reference in New Issue
Block a user