From f7b41c687390ba71ddf0bf85577174a1015f611f Mon Sep 17 00:00:00 2001 From: Daniel Stefan Date: Fri, 2 Sep 2022 18:49:52 +0300 Subject: [PATCH] fix: transfer null units error --- src/models/staging/staging.model.js | 36 ++++++++++++++++------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/models/staging/staging.model.js b/src/models/staging/staging.model.js index c75f416f..048a34c9 100644 --- a/src/models/staging/staging.model.js +++ b/src/models/staging/staging.model.js @@ -176,14 +176,16 @@ class Staging extends Model { })), ); - maker.inclusions.push( - ...makerUnitInclusions.unit - .filter((inclusion) => inclusion.action !== 'delete') - .map((inclusion) => ({ - key: inclusion.key, - value: inclusion.value, - })), - ); + if (makerUnitInclusions?.unit) { + maker.inclusions.push( + ...makerUnitInclusions.unit + .filter((inclusion) => inclusion.action !== 'delete') + .map((inclusion) => ({ + key: inclusion.key, + value: inclusion.value, + })), + ); + } taker.inclusions.push( ...takerProjectInclusions.project @@ -194,14 +196,16 @@ class Staging extends Model { })), ); - taker.inclusions.push( - ...takerUnitInclusions.unit - .filter((inclusion) => inclusion.action !== 'delete') - .map((inclusion) => ({ - key: inclusion.key, - value: inclusion.value, - })), - ); + if (takerUnitInclusions?.unit) { + taker.inclusions.push( + ...takerUnitInclusions.unit + .filter((inclusion) => inclusion.action !== 'delete') + .map((inclusion) => ({ + key: inclusion.key, + value: inclusion.value, + })), + ); + } const offerInfo = generateOffer(maker, taker); const offer = makeOffer(offerInfo);