Skip to content

Commit

Permalink
Fixed: the sequence of most rejected products and most used counts on…
Browse files Browse the repository at this point in the history
… the rejections page(#921)
  • Loading branch information
ymaheshwari1 committed Jan 29, 2025
1 parent 94d5978 commit 251dba2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/store/modules/rejection/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ const actions: ActionTree<RejectionState, RootState> = {
"field":"rejectionReasonId_s",
"mincount":1,
"limit":-1,
"sort":"index",
"type":"terms",
},
"prodductIdFacet":{
"field":"productId_s",
"mincount":1,
"limit":-1,
"sort":"index",
"type":"terms",
}
}
Expand Down Expand Up @@ -81,8 +79,15 @@ const actions: ActionTree<RejectionState, RootState> = {
}, {});
usedRejectionReasons = resp.data.docs
await store.dispatch("util/updateRejectReasons", usedRejectionReasons)
usedRejectionReasons.map((rejectionReason: any) => {
rejectionReason.count = reasonCountDetail[rejectionReason.enumId]?.count

// Added this logic as we need to display the rejections on UI in desc order of count
// If directly looping over the resp, it does not persist the rejections order on the basis of count
usedRejectionReasons = Object.keys(reasonCountDetail).map((rejectionReasonId: any) => {
const reason = usedRejectionReasons.find((reason: any) => reason.enumId === rejectionReasonId)
return {
...reason,
count: reasonCountDetail[rejectionReasonId]?.count
}
})
} else {
throw resp.data
Expand Down

0 comments on commit 251dba2

Please sign in to comment.