forked from Yara724/api
Fix SMS, and added pagination+sorting+searching for GETs
This commit is contained in:
@@ -48,6 +48,8 @@ import {
|
||||
VideoCaptureV2ResponseDto,
|
||||
} from "./dto/capture-part-v2.dto";
|
||||
import { GetMyClaimsV2ResponseDto, ClaimListItemV2Dto } from "./dto/my-claims-v2.dto";
|
||||
import { ListQueryV2Dto } from "src/common/dto/list-query-v2.dto";
|
||||
import { applyListQueryV2 } from "src/helpers/list-query-v2";
|
||||
import { ClaimDetailsV2ResponseDto } from "./dto/claim-details-v2.dto";
|
||||
import { ClaimCaseStatus } from "src/Types&Enums/claim-request-management/claim-case-status.enum";
|
||||
import { ClaimRequiredDocumentType, CarAngle } from "src/Types&Enums/claim-request-management/required-document-type.enum";
|
||||
@@ -6009,6 +6011,7 @@ export class ClaimRequestManagementService {
|
||||
async getMyClaimsV2(
|
||||
currentUserId: string,
|
||||
actor?: { sub: string; role?: string },
|
||||
query: ListQueryV2Dto = {},
|
||||
): Promise<GetMyClaimsV2ResponseDto> {
|
||||
try {
|
||||
let claims: any[];
|
||||
@@ -6050,7 +6053,25 @@ export class ClaimRequestManagementService {
|
||||
createdAt: c.createdAt,
|
||||
blameRequestId: c.blameRequestId?.toString(),
|
||||
})) as ClaimListItemV2Dto[];
|
||||
return { list, total: list.length };
|
||||
|
||||
const paged = applyListQueryV2(list, {
|
||||
publicId: (r) => r.publicId,
|
||||
createdAt: (r) => r.createdAt,
|
||||
requestNo: (r) => r.requestNo,
|
||||
status: (r) => r.status,
|
||||
searchExtras: (r) =>
|
||||
[r.claimRequestId, r.claimStatus, r.currentStep, r.blameRequestId].filter(
|
||||
Boolean,
|
||||
) as string[],
|
||||
}, query);
|
||||
|
||||
return {
|
||||
list: paged.list,
|
||||
total: paged.total,
|
||||
page: paged.page,
|
||||
limit: paged.limit,
|
||||
totalPages: paged.totalPages,
|
||||
};
|
||||
} catch (error) {
|
||||
if (error instanceof HttpException) throw error;
|
||||
this.logger.error('getMyClaimsV2 failed', error);
|
||||
|
||||
Reference in New Issue
Block a user