From 4c8e81d38d80289257339bfcc1cf652539d440c0 Mon Sep 17 00:00:00 2001 From: Adam Caouette Date: Wed, 11 Oct 2023 13:59:13 -0400 Subject: [PATCH] CSR-1384: update store method to avoid mutating original lineItems array --- src/store/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 6ca7221ac..32f004950 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -14,6 +14,7 @@ import { deleteFunnelCookie } from "@/helpers/heritage-integration/cookie-helper import { deepEqual } from "@/helpers/object-helper"; import { AppointmentTypeStrings, PREMIUM_FEE_PART_TYPE } from "@/constants/schedule-constants"; import { getQuerystringParameter } from "@/helpers/querystring-helper"; +import { deepClone } from "@/helpers/object-helper"; import { queryStrings } from "@/constants/query-strings"; import { partTypeStrings } from "@/constants/part-type-strings"; import { @@ -2274,7 +2275,8 @@ function convertGlassPieceNamingFromApi(glassArray) { } function addPricesToLineItems(lineItems, pricingLineItems) { - lineItems.forEach((lineItem) => { + const pricedLineItems = deepClone(lineItems); + pricedLineItems.forEach((lineItem) => { let lineItemIndex = pricingLineItems.findIndex( (pricingLineItem) => pricingLineItem.partNumber === lineItem.partNumber ); @@ -2286,7 +2288,7 @@ function addPricesToLineItems(lineItems, pricingLineItems) { lineItem.sellingPrice = pricedLineItem.sellingPrice; lineItem.kitPrice = pricedLineItem.kitPrice; }); - return lineItems; + return pricedLineItems; } function getFlattenedArrayOfLineItemsWithChildParts(lineItems) {