forked from Yara724/api
Added case type for all GET APIs
This commit is contained in:
@@ -10797,16 +10797,41 @@ export class ClaimRequestManagementService {
|
||||
}
|
||||
claims = [...byId.values()];
|
||||
}
|
||||
const list = (claims as any[]).map((c) => ({
|
||||
claimRequestId: c._id.toString(),
|
||||
publicId: c.publicId,
|
||||
requestNo: c.requestNo,
|
||||
status: c.status,
|
||||
claimStatus: c.claimStatus || "PENDING",
|
||||
currentStep: c.workflow?.currentStep || "",
|
||||
createdAt: c.createdAt,
|
||||
blameRequestId: c.blameRequestId?.toString(),
|
||||
})) as ClaimListItemV2Dto[];
|
||||
const blameIdsForList = [
|
||||
...new Set(
|
||||
(claims as any[])
|
||||
.map((c) => c.blameRequestId?.toString())
|
||||
.filter((id): id is string => !!id),
|
||||
),
|
||||
];
|
||||
const blamesForList =
|
||||
blameIdsForList.length > 0
|
||||
? ((await this.blameRequestDbService.find(
|
||||
{ _id: { $in: blameIdsForList.map((id) => new Types.ObjectId(id)) } },
|
||||
{ lean: true, select: "type creationMethod" },
|
||||
)) as any[])
|
||||
: [];
|
||||
const blameByIdForList = new Map<string, any>(
|
||||
blamesForList.map((b) => [String(b._id), b]),
|
||||
);
|
||||
|
||||
const list = (claims as any[]).map((c) => {
|
||||
const blameForItem = c.blameRequestId
|
||||
? blameByIdForList.get(c.blameRequestId.toString())
|
||||
: undefined;
|
||||
return {
|
||||
claimRequestId: c._id.toString(),
|
||||
publicId: c.publicId,
|
||||
requestNo: c.requestNo,
|
||||
status: c.status,
|
||||
claimStatus: c.claimStatus || "PENDING",
|
||||
currentStep: c.workflow?.currentStep || "",
|
||||
createdAt: c.createdAt,
|
||||
blameRequestId: c.blameRequestId?.toString(),
|
||||
blameType: blameForItem?.type ?? undefined,
|
||||
creationMethod: blameForItem?.creationMethod ?? undefined,
|
||||
};
|
||||
}) as ClaimListItemV2Dto[];
|
||||
|
||||
const paged = applyListQueryV2(
|
||||
list,
|
||||
@@ -10856,6 +10881,15 @@ export class ClaimRequestManagementService {
|
||||
}
|
||||
await this.assertActorCanViewClaimV2(claim, currentUserId, actor);
|
||||
|
||||
const blameForDetail = claim.blameRequestId
|
||||
? ((
|
||||
await this.blameRequestDbService.find(
|
||||
{ _id: new Types.ObjectId(claim.blameRequestId.toString()) },
|
||||
{ lean: true, select: "type creationMethod" },
|
||||
)
|
||||
)[0] ?? null)
|
||||
: null;
|
||||
|
||||
const hasCapture = (data: any, key: string) =>
|
||||
data && (data instanceof Map ? data.get(key) : data[key]);
|
||||
|
||||
@@ -11011,6 +11045,8 @@ export class ClaimRequestManagementService {
|
||||
nextStep: claim.workflow?.nextStep,
|
||||
blameRequestId: claim.blameRequestId?.toString(),
|
||||
blameRequestNo: claim.blameRequestNo,
|
||||
blameType: (blameForDetail as any)?.type ?? undefined,
|
||||
creationMethod: (blameForDetail as any)?.creationMethod ?? undefined,
|
||||
...(ownerData ? { owner: ownerData } : {}),
|
||||
vehicle: claim.vehicle,
|
||||
selectedParts: selectedNormDetails,
|
||||
|
||||
Reference in New Issue
Block a user