Skip to content

Commit

Permalink
Add sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
dk-bcps committed Dec 19, 2024
1 parent d4d0955 commit 66dad3c
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions backend/src/v1/complaint/complaint.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2074,6 +2074,24 @@ export class ComplaintService {
return outcomeData.getCaseFileByLeadId;
};

const _sortRecords = (first: any, second: any): number => {
if (first.fileType < second.fileType) {
if (first.date < second.date) {
return -2;
} else {
return -1;
}
}
if (first.fileType > second.fileType) {
if (first.date > second.date) {
return 1;
} else {
return 2;
}
}
return 0;
};

try {
if (complaintType) {
builder = this._generateQueryBuilder(complaintType);
Expand Down Expand Up @@ -2200,7 +2218,8 @@ export class ComplaintService {
date: _applyTimezone(item.date, tz, "datetime"),
fileType: getFileType(item.name),
};
});
})
.sort((first, second) => _sortRecords(first, second));
data.hasComplaintAttachments = data.cAtts?.length > 0;

data.oAtts = attachments
Expand All @@ -2211,7 +2230,8 @@ export class ComplaintService {
date: _applyTimezone(item.date, tz, "datetime"),
fileType: getFileType(item.name),
};
});
})
.sort((first, second) => _sortRecords(first, second));

data.hasOutcomeAttachments = data.oAtts?.length > 0;

Expand Down

0 comments on commit 66dad3c

Please sign in to comment.