diff --git a/src/helpers/recal-helper.js b/src/helpers/recal-helper.js index e72c2d63..bb1a092c 100644 --- a/src/helpers/recal-helper.js +++ b/src/helpers/recal-helper.js @@ -25,6 +25,21 @@ export function getTopLevelGlassPartsWithRecal(glassParts) { return glassParts.filter((gp) => isRecalPartOrHasChildRecalPart(gp)); } +export function getRecalParts(glassParts) { + if (!glassParts) { + return null; + } + return glassParts.flatMap((gp) => { + if (isRecalPart(gp)) { + return [gp]; + } + if (gp.childParts && gp.childParts.length > 0) { + return gp.childParts.filter((cp) => isRecalPart(cp)); + } + return []; + }); +} + export function getItemsWithoutRecalParts(lineItemsArray) { if (!lineItemsArray || !Array.isArray(lineItemsArray)) return null; const firstLevelFiltered = deepClone(lineItemsArray).filter((li) => !isRecalPart(li));