Skip to content

Commit

Permalink
Merge pull request #38 from OpenLMIS/OLMIS-7906-fix
Browse files Browse the repository at this point in the history
OLMIS-7906: fix to await facilityData
  • Loading branch information
dszafranek authored Apr 11, 2024
2 parents ed54295 + e5ab485 commit 8b6b314
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/buq/components/MOHApproval/MohForFinalApproval.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ const MohForFinalApproval = ({ loadingModalService, facilityService }) => {
};

const combineData = async () => {
let items = [];
buqsData.map((buq, index) => {
const facilityData = facilityService.get(buq.bottomUpQuantification.facilityId);
const promises = buqsData.map(async (buq, index) => {
const facilityData = await facilityService.get(buq.bottomUpQuantification.facilityId);

const calc = buq.calculatedGroupsCosts;

Expand All @@ -66,18 +65,24 @@ const MohForFinalApproval = ({ loadingModalService, facilityService }) => {
others: calc.Others,
};

items.push({
return {
buq,
calculatedGroupsCosts: calculatedGroups,
idCheckbox: `${buq.bottomUpQuantification.id}${buq.bottomUpQuantification.facilityId}`,
facilityName: facilityData.$$state.value.name,
facilityType: facilityData.$$state.value.type.name,
facilityName: facilityData.name,
facilityType: facilityData.type.name,
key: index + buq.bottomUpQuantification.id,
})
};
});

setData(items);
loadingModalService.close();
})
Promise.all(promises)
.then((data) => {
setData(data);
loadingModalService.close();
})
.catch(() => {
loadingModalService.close();
});
};

const handleFinalApproveAction = () => {
Expand Down

0 comments on commit 8b6b314

Please sign in to comment.