Skip to content

Commit 667ed1b

Browse files
authored
Update ResourceBookingEventHandler.js
fix async await foreach
1 parent f4c562f commit 667ed1b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/eventHandlers/ResourceBookingEventHandler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ async function deleteWorkPeriods (payload) {
254254
* @returns {undefined}
255255
*/
256256
async function _createWorkPeriods (periods, resourceBookingId) {
257-
Promise.all(_.forEach(periods, async period => await WorkPeriodService.createWorkPeriod(helper.getAuditM2Muser(),
257+
await Promise.all(_.map(periods, async period => await WorkPeriodService.createWorkPeriod(helper.getAuditM2Muser(),
258258
{
259259
resourceBookingId: resourceBookingId,
260260
startDate: period.startDate,
@@ -270,7 +270,7 @@ async function _createWorkPeriods (periods, resourceBookingId) {
270270
* @returns {undefined}
271271
*/
272272
async function _updateWorkPeriods (periods) {
273-
Promise.all(_.forEach(periods, async period => await WorkPeriodService.partiallyUpdateWorkPeriod(helper.getAuditM2Muser(),
273+
await Promise.all(_.map(periods, async period => await WorkPeriodService.partiallyUpdateWorkPeriod(helper.getAuditM2Muser(),
274274
period.id,
275275
{
276276
daysWorked: period.daysWorked
@@ -283,7 +283,7 @@ async function _updateWorkPeriods (periods) {
283283
* @returns {undefined}
284284
*/
285285
async function _deleteWorkPeriods (workPeriods) {
286-
Promise.all(_.forEach(workPeriods,
286+
await Promise.all(_.map(workPeriods,
287287
async workPeriod => await WorkPeriodService.deleteWorkPeriod(helper.getAuditM2Muser(), workPeriod.id)))
288288
}
289289

0 commit comments

Comments
 (0)