diff --git a/src/store/index.js b/src/store/index.js index dd8cf38af..50c6c1612 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2173,7 +2173,7 @@ export const actions = { saveSupportingItems(context, supportingItems) { syncLineItemIds(supportingItems, context.state.order.lineItems.supportingItems); - if (!deepEqual(supportingItems, context.state.order.lineItems.supportingItems)) { + if (!supportingItemsEqual(supportingItems, context.state.order.lineItems.supportingItems)) { context.dispatch(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES); } addGuidToLineItemsIfNotAlreadyThere(supportingItems); @@ -2970,6 +2970,7 @@ function syncLineItemIds(lineItemsWithoutIds, lineItemsWithIds) { } }); if (matchedLineItemIndex > -1) { + // Remove the matched line item clonedLineItemsWithIds.splice(matchedLineItemIndex, 1); } }); @@ -2986,6 +2987,21 @@ function providersEqual(providerA, providerB) { //TODO: Change back to deepEqual once zipCodeCtu is added to saveSession. } +function supportingItemsEqual(supportingItemsA, supportingItemsB) { + if (supportingItemsA.length != supportingItemsB.length) { + return false; + } + const sortedA = supportingItemsA.slice().sort(); + const sortedB = supportingItemsB.slice().sort(); + for (let i = 0; i < sortedA.length; i++) { + if (sortedA[i].partNumber != sortedB[i].partNumber || + sortedA[i].partType != sortedB[i].partType) { + return false; + } + } + return true; +} + // This function will verify schedule info is still valid. // check to see if we have an appointment date on the order object. // if so, make sure it's not in the past. if in the past, clear schedule info in store.