From 73293a721921c769d74e3c5e25f0c932d557521f Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Wed, 15 May 2024 10:05:27 -0400 Subject: [PATCH 1/4] CSR-2076 | Fix line item IDs mismatch --- src/store/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/store/index.js b/src/store/index.js index 5a153e731..dd8cf38af 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2172,6 +2172,7 @@ export const actions = { }, saveSupportingItems(context, supportingItems) { + syncLineItemIds(supportingItems, context.state.order.lineItems.supportingItems); if (!deepEqual(supportingItems, context.state.order.lineItems.supportingItems)) { context.dispatch(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES); } From 252d5454a1494b2340821f23ebbfbc9982908007 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Mon, 20 May 2024 10:00:25 -0400 Subject: [PATCH 2/4] Change deepequals to specific check --- src/store/index.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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. From 4830a53fb747983adf23dac395a050f6cd12f982 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Mon, 20 May 2024 10:07:51 -0400 Subject: [PATCH 3/4] CSR-2076 | Make equals statement more robust --- src/store/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/store/index.js b/src/store/index.js index 50c6c1612..4ee3f3c7a 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2988,6 +2988,12 @@ function providersEqual(providerA, providerB) { } function supportingItemsEqual(supportingItemsA, supportingItemsB) { + if (typeof supportingItemsA !== typeof supportingItemsB) { + return false; + } + if (supportingItemsA === null || supportingItemsB === null) { + return supportingItemsA === supportingItemsB; + } if (supportingItemsA.length != supportingItemsB.length) { return false; } From 8635ab63e764f9263c9f46d3310ac16db35890f1 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Mon, 20 May 2024 10:17:58 -0400 Subject: [PATCH 4/4] CSR-2076 | Formatting --- src/store/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 4ee3f3c7a..aa1979e0a 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -3000,10 +3000,12 @@ function supportingItemsEqual(supportingItemsA, supportingItemsB) { 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; - } + if ( + sortedA[i].partNumber != sortedB[i].partNumber || + sortedA[i].partType != sortedB[i].partType + ) { + return false; + } } return true; }