1
0
forked from Yara724/api

Merge branch 'main' of git.ittalie.com:s.yahyaee/yara724-api

This commit is contained in:
SepehrYahyaee
2026-04-22 09:11:42 +03:30
15 changed files with 509 additions and 23 deletions

View File

@@ -0,0 +1,49 @@
import { CaseStatus } from "src/Types&Enums/blame-request-management/caseStatus.enum";
import { ClaimCaseStatus } from "src/Types&Enums/claim-request-management/claim-case-status.enum";
/** Blame: early workflow before expert queue / resend / signatures / terminals. */
const BLAME_IN_PROGRESS_STATUSES = new Set<string>([
CaseStatus.OPEN,
CaseStatus.WAITING_FOR_SECOND_PARTY,
]);
/**
* Claim: user flow before submission is complete (analog to `ClaimWorkflowStep.USER_SUBMISSION_COMPLETE`).
*/
const CLAIM_IN_PROGRESS_STATUSES = new Set<string>([
ClaimCaseStatus.CREATED,
ClaimCaseStatus.SELECTING_OUTER_PARTS,
ClaimCaseStatus.SELECTING_OTHER_PARTS,
ClaimCaseStatus.UPLOADING_REQUIRED_DOCUMENTS,
ClaimCaseStatus.CAPTURING_PART_DAMAGES,
]);
export function blameCaseStatusToReportBucket(status: string): string {
if (BLAME_IN_PROGRESS_STATUSES.has(status)) return "IN_PROGRESS";
return status;
}
export function claimCaseStatusToReportBucket(status: string): string {
if (CLAIM_IN_PROGRESS_STATUSES.has(status)) return "IN_PROGRESS";
return status;
}
/** Keys returned for blame V2 expert report (IN_PROGRESS + each native post-early status). */
export function initialBlameExpertReportBuckets(): Record<string, number> {
const out: Record<string, number> = { all: 0, IN_PROGRESS: 0 };
for (const s of Object.values(CaseStatus)) {
if (BLAME_IN_PROGRESS_STATUSES.has(s)) continue;
out[s] = 0;
}
return out;
}
/** Keys returned for claim V2 expert report. */
export function initialClaimExpertReportBuckets(): Record<string, number> {
const out: Record<string, number> = { all: 0, IN_PROGRESS: 0 };
for (const s of Object.values(ClaimCaseStatus)) {
if (CLAIM_IN_PROGRESS_STATUSES.has(s)) continue;
out[s] = 0;
}
return out;
}

View File

@@ -0,0 +1,29 @@
import { ExpertModel } from "src/users/entities/schema/expert.schema";
import { DamageExpertModel } from "src/users/entities/schema/damage-expert.schema";
import { ExpertProfileSnapshot } from "src/request-management/entities/schema/expert-profile-snapshot.schema";
export function snapshotFromFieldExpert(
doc: ExpertModel | null | undefined,
): ExpertProfileSnapshot | undefined {
if (!doc) return undefined;
return {
firstName: doc.firstName ?? undefined,
lastName: doc.lastName ?? undefined,
email: doc.email ?? undefined,
insuActivityCo: doc.insuActivityCo ?? undefined,
mobile: (doc.mobile ?? doc.phone) ?? undefined,
};
}
export function snapshotFromDamageExpert(
doc: DamageExpertModel | null | undefined,
): ExpertProfileSnapshot | undefined {
if (!doc) return undefined;
return {
firstName: doc.firstName ?? undefined,
lastName: doc.lastName ?? undefined,
email: doc.email ?? undefined,
insuActivityCo: doc.insuActivityCo ?? undefined,
mobile: doc.mobile ?? undefined,
};
}