From 51fb83932d38a84b0a29faa63f4f23c1d696e34f Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Thu, 12 Sep 2024 12:28:32 -0400 Subject: [PATCH] Update `containsRecalPart` to accept both lineitems formats --- src/helpers/recal-helper.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/helpers/recal-helper.js b/src/helpers/recal-helper.js index d6b1d044f..fa33e7849 100644 --- a/src/helpers/recal-helper.js +++ b/src/helpers/recal-helper.js @@ -19,7 +19,20 @@ export function containsRecalParts(lineItems) { if (!lineItems) { return false; } - return lineItems.some((li) => isRecalPartOrHasChildRecalPart(li)); + + if (Array.isArray(lineItems)) { + return lineItems.some((li) => isRecalPartOrHasChildRecalPart(li)); + } else { + // complex object form -- flatten and re-call. + const flattened = [ + ...(lineItems.glassParts ?? []), + ...(lineItems.supportingItems ?? []), + ...(lineItems.vaps ?? []), + ...(lineItems.promos ?? []), + ]; + + return flattened.some((li) => isRecalPartOrHasChildRecalPart(li)); + } } export function getItemsWithoutRecalParts(lineItems) {