Skip to content

Commit

Permalink
Merge pull request #922 from ymaheshwari1/#921
Browse files Browse the repository at this point in the history
Improved: code to display the rejection reason description in place of reason id on rejections page and improved sequence of items and reasons inside most used cards(#921)
  • Loading branch information
ymaheshwari1 authored Jan 29, 2025
2 parents d92d22e + cbd8d10 commit db0eef1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
23 changes: 15 additions & 8 deletions src/store/modules/rejection/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { escapeSolrSpecialChars, prepareSolrQuery } from '@/utils/solrHelper'
import { UtilService } from '@/services/UtilService'
import logger from '@/logger'
import { getCurrentFacilityId } from '@/utils'
import store from '@/store'

const actions: ActionTree<RejectionState, RootState> = {
async fetchRejectionStats({ commit, state }) {
Expand All @@ -34,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 All @@ -67,7 +66,7 @@ const actions: ActionTree<RejectionState, RootState> = {
},
"fieldList": ["description", "enumId", "enumName", "enumTypeId", "sequenceNum"],
"distinct": "Y",
"entityName": "EnumTypeChildAndEnum",
"entityName": "Enumeration",
"viewSize": reasonIds.length, //There won't we rejection reasons more than 20, hence fetching detail for all the reasons at once
"orderBy": "sequenceNum"
}
Expand All @@ -79,8 +78,16 @@ const actions: ActionTree<RejectionState, RootState> = {
return reasonDetail;
}, {});
usedRejectionReasons = resp.data.docs
usedRejectionReasons.map((rejectionReason: any) => {
rejectionReason.count = reasonCountDetail[rejectionReason.enumId]?.count
await store.dispatch("util/updateRejectReasons", usedRejectionReasons)

// 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 All @@ -98,8 +105,6 @@ const actions: ActionTree<RejectionState, RootState> = {
async fetchRejectedOrders({ commit, dispatch, state }, payload) {
let orders = [] as any, orderList = [] as any, total = 0
const rejectedOrderQuery = JSON.parse(JSON.stringify(state.rejectedOrders.query))



const filters = {
rejectedFrom_txt_en: { value: escapeSolrSpecialChars(getCurrentFacilityId()) },
Expand Down Expand Up @@ -136,6 +141,8 @@ const actions: ActionTree<RejectionState, RootState> = {
total = resp.data.grouped.orderId_s.ngroups
orders = resp.data.grouped.orderId_s.groups

const rejectionReasons = store.getters["util/getRejectReasons"]

orders = orders.map((order: any) => {
const orderItemDocs = order.doclist.docs.map((doc: any) => {
return {
Expand All @@ -148,7 +155,7 @@ const actions: ActionTree<RejectionState, RootState> = {
rejectedBy: doc.rejectedBy_txt_en,
rejectedAt: doc.rejectedAt_dt,
rejectionReasonId: doc.rejectionReasonId_txt_en,
rejectionReasonDesc: doc.rejectionReasonDesc_txt_en,
rejectionReasonDesc: rejectionReasons?.find((reason: any) => reason.enumId === doc.rejectionReasonId_txt_en)?.description || doc.rejectionReasonId_txt_en,
brokeredAt: doc.brokeredAt_dt,
brokeredBy: doc.brokeredBy_txt_en,
};
Expand Down
7 changes: 3 additions & 4 deletions src/views/Rejections.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@

<div class="rejection-search">
<ion-searchbar class="searchbar" :placeholder="translate('Search orders')" v-model="queryString" @keyup.enter="updateQueryString($event.target.value)"/>
<ion-label>
{{ rejectedOrders.total }} {{translate("rejections") }}
</ion-label>

<div></div>
<ion-button :disabled="!rejectedOrders.list.length" expand="block" fill="outline" @click="downloadRejections()" class="ion-margin-end">
<ion-icon slot="end" :icon="cloudDownloadOutline" />{{ translate("Download rejections") }}
</ion-button>
Expand Down Expand Up @@ -360,7 +357,9 @@ export default defineComponent({
.searchbar{
padding-top: 0;
padding-bottom: 0;
}
ion-card-header {
display: flex;
flex-direction: row;
Expand Down

0 comments on commit db0eef1

Please sign in to comment.