forked from Yara724/api
Merge branch 'main' into integrate-my-work
This commit is contained in:
@@ -2963,8 +2963,13 @@ export class RequestManagementService {
|
||||
request: RequestManagementModel,
|
||||
user: any,
|
||||
): Promise<void> {
|
||||
// If user is not an expert, no verification needed (normal flow)
|
||||
if (user.role !== RoleEnum.EXPERT && user.role !== RoleEnum.DAMAGE_EXPERT) {
|
||||
// If user is not an expert type, no verification needed (normal flow)
|
||||
const expertRoles = [
|
||||
RoleEnum.EXPERT,
|
||||
RoleEnum.DAMAGE_EXPERT,
|
||||
RoleEnum.FIELD_EXPERT,
|
||||
];
|
||||
if (!expertRoles.includes(user.role)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3115,6 +3120,60 @@ export class RequestManagementService {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* List all expert-initiated blame files for the current field expert (their panel).
|
||||
* Only files where initiatedBy === current user are returned.
|
||||
*/
|
||||
async getMyExpertInitiatedFiles(expert: any): Promise<any[]> {
|
||||
const expertId = new Types.ObjectId(expert.sub);
|
||||
const files = await this.requestManagementDbService.findAll({
|
||||
expertInitiated: true,
|
||||
initiatedBy: expertId,
|
||||
});
|
||||
return (files || []).map((f) => ({
|
||||
_id: f._id,
|
||||
requestNumber: f.requestNumber,
|
||||
type: f.type,
|
||||
creationMethod: f.creationMethod,
|
||||
blameStatus: f.blameStatus,
|
||||
currentStep: f.currentStep,
|
||||
nextStep: f.nextStep,
|
||||
createdAt: f.createdAt,
|
||||
steps: f.steps,
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Single endpoint handler: complete all blame-needed data.
|
||||
* Routes to THIRD_PARTY or CAR_BODY completion based on request type.
|
||||
*/
|
||||
async completeBlameData(
|
||||
expert: any,
|
||||
requestId: string,
|
||||
formData: any,
|
||||
): Promise<RequestManagementDtoRs> {
|
||||
const request = await this.requestManagementDbService.findOne(requestId);
|
||||
if (!request) {
|
||||
throw new NotFoundException("Request not found");
|
||||
}
|
||||
if (!request.expertInitiated) {
|
||||
throw new BadRequestException(
|
||||
"This endpoint is only for expert-initiated files",
|
||||
);
|
||||
}
|
||||
await this.verifyExpertAccess(request, expert);
|
||||
|
||||
if (request.type === "THIRD_PARTY") {
|
||||
return this.expertCompleteThirdPartyForm(expert, requestId, formData);
|
||||
}
|
||||
if (request.type === "CAR_BODY") {
|
||||
return this.expertCompleteCarBodyForm(expert, requestId, formData);
|
||||
}
|
||||
throw new BadRequestException(
|
||||
"Unknown file type. Must be THIRD_PARTY or CAR_BODY.",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expert completes all information for IN_PERSON THIRD_PARTY file at once
|
||||
* This replaces the step-by-step flow for experts filling files on-site
|
||||
|
||||
Reference in New Issue
Block a user