forked from Yara724/api
YARA-886
This commit is contained in:
@@ -239,13 +239,15 @@ export class ExpertClaimService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a deep-cloned `evaluation` payload with resolved `signLink`s for the
|
||||
* fields that carry a user signature:
|
||||
* Build a deep-cloned `evaluation` payload with resolved file URLs the
|
||||
* front-end can render directly:
|
||||
*
|
||||
* - `damageExpertReply.userComment.signLink`
|
||||
* - `damageExpertReplyFinal.userComment.signLink`
|
||||
* - `ownerInsurerApproval.signLink`
|
||||
* - `ownerPricedPartsApproval.signLink`
|
||||
* - `damageExpertReply.parts[i].factorLink` (ObjectId → URL)
|
||||
* - `damageExpertReplyFinal.parts[i].factorLink` (ObjectId → URL)
|
||||
*
|
||||
* Returns `undefined` when there's no evaluation to enrich.
|
||||
*/
|
||||
@@ -255,16 +257,21 @@ export class ExpertClaimService {
|
||||
if (!evaluation || typeof evaluation !== "object") return undefined;
|
||||
const ev = JSON.parse(JSON.stringify(evaluation)) as Record<string, unknown>;
|
||||
|
||||
const enrichReplyUserComment = async (key: string) => {
|
||||
const enrichReply = async (key: string) => {
|
||||
const reply = ev[key] as Record<string, unknown> | undefined;
|
||||
const uc = reply?.userComment as Record<string, unknown> | undefined;
|
||||
if (!reply) return;
|
||||
const uc = reply.userComment as Record<string, unknown> | undefined;
|
||||
if (uc?.signDetailId != null) {
|
||||
const signLink = await this.claimSignLinkFromId(uc.signDetailId);
|
||||
(reply as Record<string, unknown>).userComment = { ...uc, signLink };
|
||||
reply.userComment = { ...uc, signLink };
|
||||
}
|
||||
// Resolve each `parts[].factorLink` ObjectId to a downloadable URL.
|
||||
// `populateFactorLinks` mutates in place — safe here because `ev` was
|
||||
// deep-cloned via JSON above, so we never touch the live mongoose doc.
|
||||
await this.populateFactorLinks(reply);
|
||||
};
|
||||
await enrichReplyUserComment("damageExpertReply");
|
||||
await enrichReplyUserComment("damageExpertReplyFinal");
|
||||
await enrichReply("damageExpertReply");
|
||||
await enrichReply("damageExpertReplyFinal");
|
||||
|
||||
const enrichApproval = async (key: string) => {
|
||||
const o = ev[key] as Record<string, unknown> | undefined;
|
||||
|
||||
Reference in New Issue
Block a user