forked from Yara724/api
FIXED FILE REVIEWER GET ALL
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
assertBlameCaseForExpertTenant,
|
||||
blameCaseAccessibleToExpert,
|
||||
blameCaseInitiatedByFieldExpert,
|
||||
blameCaseTouchesClient,
|
||||
requireActorClientKey,
|
||||
} from "src/helpers/tenant-scope";
|
||||
import {
|
||||
@@ -438,6 +439,9 @@ export class ExpertBlameService {
|
||||
if (actor.role === RoleEnum.FIELD_EXPERT) {
|
||||
return this.getFieldExpertBlameListV2(actor, query);
|
||||
}
|
||||
if (actor.role === RoleEnum.FILE_REVIEWER) {
|
||||
return this.getFileReviewerBlameListV2(actor, query);
|
||||
}
|
||||
requireActorClientKey(actor);
|
||||
const expertId = actor.sub;
|
||||
|
||||
@@ -579,6 +583,44 @@ export class ExpertBlameService {
|
||||
return pagedResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blame inbox for FILE_REVIEWER — all expert-initiated IN_PERSON files that
|
||||
* have been sealed by a FileMaker (WAITING_FOR_FILE_REVIEWER) and belong to
|
||||
* this reviewer's insurance company (clientKey).
|
||||
*
|
||||
* Once the FileReviewer completes their steps the file moves to
|
||||
* WAITING_FOR_EXPERT (via upload-video), after which it is visible in the
|
||||
* standard expert-blame panel as usual.
|
||||
*/
|
||||
private async getFileReviewerBlameListV2(
|
||||
actor: { sub: string; clientKey?: string },
|
||||
query: ListQueryV2Dto = {},
|
||||
): Promise<AllRequestDtoRsV2> {
|
||||
const clientKey = requireActorClientKey(actor);
|
||||
|
||||
const allSealed = (await this.blameRequestDbService.find(
|
||||
{
|
||||
expertInitiated: true,
|
||||
status: {
|
||||
$in: [
|
||||
CaseStatus.WAITING_FOR_FILE_REVIEWER,
|
||||
CaseStatus.WAITING_FOR_EXPERT,
|
||||
CaseStatus.COMPLETED,
|
||||
],
|
||||
},
|
||||
},
|
||||
{ lean: true },
|
||||
)) as Record<string, unknown>[];
|
||||
|
||||
// Scope to this reviewer's insurance company via blame party clientId
|
||||
const visibleCases = allSealed.filter((doc) =>
|
||||
blameCaseTouchesClient(doc, clientKey),
|
||||
);
|
||||
|
||||
const pagedResult = await this.paginateBlameListV2(visibleCases, query);
|
||||
return pagedResult;
|
||||
}
|
||||
|
||||
private async paginateBlameListV2(
|
||||
visibleCases: Record<string, unknown>[],
|
||||
query: ListQueryV2Dto,
|
||||
@@ -727,6 +769,8 @@ export class ExpertBlameService {
|
||||
secondParty?.vehicle?.inquiry?.mapped?.CarName ||
|
||||
"",
|
||||
},
|
||||
needsFileReviewerCompletion:
|
||||
String(doc.status ?? "") === CaseStatus.WAITING_FOR_FILE_REVIEWER,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user